This year, my students and I have been learning the basics of programming using a programming language called Processing (see previous entry). One of the great features of working with Processing is that you can run your programs on a variety of platforms, including your handheld devices. After just a couple of weeks of playing around, I was able to create a program that ran on my Android phone. I have been using my kids as the target audience for my creations so i haven't thought much about the details, such as customizing the icon or how to upload the app to Google Play (aka the Android Market).
I thought I would share the code I used to create the Android installer in case anyone is interested. I got it from here but his instructions are for Windows and I am currently using a Mac. I had to modify a couple of steps. You can find more thorough explanations on the Processing wiki here and here is a post that goes through uploading your project to the Android market. I haven't tried it yet.
You will need to install the Java Development Kit (JDK) and the Android Software Development Kit (SDK) before we get started. These include the following tools, which we will be using in the process:
1) You will be running the following commands from a terminal:
keytool, jarsigner, zipalign, ant
If you get errors along the way, make sure that you can run these commands from a terminal. You may need to download ant separately. The others should have been installed with JDK and the Android SDK.
I created a simple project called 'test01'. You can just replace test01 with the name of your sketch and the name (ben) and path (benjamincooperman) to yours. It makes things easier if there are no spaces in the name. Here's what I did:
1) By default, new projects are in 'standard' mode. At the top right, you will see 'standard' in a little box. Change it to 'Android'. You may have trouble if your project includes any additional libraries, such as the Minim library for using sounds. There is probably an Android library that does the same thing but you will need to research that. In one case, I was using Minim for sound, but as an Android project, I had to use one called 'apwidgets'. The nice folks on the Processing forum helped me work out how to switch libraries and you can check out the thread here.
2) Export your Android project by going to file > Export Android Project. You will see that there is an option to export as a signed package but that feature has not been implemented yet so these instructions should work for you in the meantime.
2) Open a terminal and browse to the android folder inside your sketch folder. On a Mac, the easiest way to do this is to type 'cd ' then locate the android folder in your sketch folder and click and drag it onto the terminal. (mine was: /Users/benjamincooperman/Documents/Processing/test01/android) It will look something like this:
3) Next, type the following into the terminal and hit enter:
keytool -genkey -v -keystore test01-release-key.keystore -alias ben -keyalg RSA -keysize 2048 -validity 10000
It will ask for a password. Put something in. It will ask you to re-type the password. Then, there will be a series of questions. I answered the first one (what is your first and last name) with just my first (ben) and then I ignored the rest of the questions and just hit enter until I got to:
Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?
Type 'yes' and hit enter and enter again to enter the password you already used.
4) Type the following into the terminal, hit enter and wait a bit for it to finish:
5) Then, type the following and hit enter after which it will ask you for the password from step 3.
jarsigner -verbose -keystore test01-release-key.keystore /Users/benjamincooperman/Documents/Processing/test01/android/bin/test01-release-unsigned.apk ben
6) Next, type:
jarsigner -verify /Users/benjamincooperman/Documents/Processing/test01/android/bin/test01-release-unsigned.apk
It should say 'jar verified'.
/Users/benjamincooperman/Documents/Processing/test01/android/zipalign -v 4 /Users/benjamincooperman/Documents/Processing/test01/android/bin/test01-release-unsigned.apk test01.apk
If all went well, it should say 'Verification successful' and you will now have a test01.apk file in the android folder that you can install on your phone. Most file managers that you find in the Android Market allow you to install software. Just be sure to have have your phone set up so that you can install from unknown sources. You can find that under Development Settings.
I tried to make this as clear and simple as possible since these are the same instructions that I am giving to my students. If you see any errors or you have suggestions, please let me know.