In this post, I will explain how to install Phratch on an Android device. I created the .apk file for an ARM architecture. The following instructions are based on this page.

Prerequirements:
  • Download Android SDK: http://developer.android.com/sdk/index.html
  • Ant should be installed: http://ant.apache.org/
Image preparation:

First, download  a Pharo 2.0 image and execute the following code. It loads the necessary code for Android support and the Phratch package. Deprecation raiseWarning: false; showWarning: false.

"Installation of Android support"
Gofer new
 url: 'http://source.squeak.org/VMMaker';
 package: 'Android-Base';
 load.
SmalltalkImage checkSourcesFileAvailability: false.
SmalltalkImage checkChangesFileAvailability: false.
"2 - installation of Phratch"
Gofer it
 url: 'http://smalltalkhub.com/mc/JLaval/Phratch/main'
 username: ''
 password: '';
 package: 'ConfigurationOfPhratch';
 load.
(Smalltalk at: #ConfigurationOfPhratch) loadBleedingEdge.

Then, you can execute the following lines that makes Phratch be in User mode:

StartupLoader default removeAllScriptsFromAllDirectories; initialize.
PhratchFrameMorph open saveImageForEndUserSilently.
Image splitting

Now, split your image:

split -d -b 1m /path/to/myapplication.image myapplication.

In macosX, the option -d does not exist. It means that you should remove it and rename all created files with extensions as .00, .01, .02, …

Creation of the Android project

Create a new folder for the project. Inside it, unzip the makevm.zip (https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/).
Go inside the dir, and, inside it, unzip the nativeVM-xxx.zip (https://ci.inria.fr/pharo-contribution/view/VM/job/CogDroid/). I use the arm file.

Then do

 mkdir -p src/phratch/eu/android

Then create a .java file in src/phratch/eu/android/Phratch.java, which contains:

package phratch.eu.android;
 import org.golubovsky.cogstack.CogActivity;
 public class Phratch extends CogActivity {
 }

In assets/image, push the image splitted file (files with extension .00, .01, …), and run:

ls -l assets/image/

Make sure subdirectory assets/zipped exists. From https://code.google.com/p/phratch/downloads/list, download in this folder the files ScratchSkin.zip, Manual.zip, locale.zip, Media.zip, and Help.zip.

Customize of the Android project

Now, comes the need to change files. Go back in the makevm folder.

In AndroidManifest.xml

  • change @@PACKAGE@@ by “phratch.eu.android”
  • change @@ACTIVITY@@ by “Phratch”

In build.xml

  • change @@BUILD@@ by “Phratch-android”

In res/values/strings.xml

  • change @@BUILD@@ by Phratch-android

In local.properties

  • change the line sdk.dir by the full path of your sdk, mine is sdk.dir=/Users/janniklaval/Desktop/phratch-and/makevm/sdk

In project.properties, change the two following lines:

  • target=android-4
  • android.library.reference.1=../../project/

by

  • target=android-17
  • android.library.reference.1=project/

In project/local.properties

  • change the line sdk.dir by the full path of your sdk, mine is sdk.dir=/Users/janniklaval/Desktop/phratch-and/makevm/sdk

In project/project.properties, change the following line:

  • target=android-4

by

  • target=android-17

In res/drawable/, you can replace icons.

Finish the creation of the .apk

Run the commands:

 ant clean
 ant debug

You can run

 ant release

The installable apk file will be under bin: Phratch-android-debug.apk.

Leave a reply

required

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>