It’s holiday time, and what better way to spend your spare time than to learn a new scripting language or dabble with some Android development. In anticipation of my long overseas flight, I decided to gear up for some scripting and Android hacking while on the plane. I decided to see what sort of options were available, keeping the following goals in mind:
- I would like to learn Python
- I would like to be able to hack together an Android app using scripting (Python, Ruby, JavaScript, HTML, etc.)
- I would like to be able to mess around with OpenGL and maybe even write a simple game uililising graphics (e.g. a simple Labyrinth type game)
- It must be quick and easy and work offline
Obviously, developing on a phone is not practical for various reasons: they make you put phones off, even if in airplane mode, the screen is too small, and you really need a physical keyboard. Battery life might also be a concern. Luckily, I have an Asus Eee Pad Transformer, for which I bought the keyboard dock. So, the idea is to be able to hack scripts and apps on the Android tablet itself.
The contenders:
After some digging around, these are the options I found:
- Terminal IDE – a full-on Android development environment for Android. Too clunky and complex.
- Java IDE (Android) – also full-on Android development environment for Android. Seems easier and neater than Terminal IDE, but still too clunky and complex for airplane hacking.
- SL4A (Scripting layer 4 Android) – exactly the sort of thing I was looking for. Python, Lua, PHP, Ruby, HTML, and JavaScript are all available as languages.
- Ruboto IRB – JRuby scripting environment that provides direct access to the Android API. Very powerful environment
- Touchqode – One of several syntax-highlighting text editors for coding on your Android device
- Learn Python – book in the form of an app that teaches Python programming.
From the above, it should be clear that SL4A and Ruboto IRB are the two worth installing. So let’s look at the pro’s and con’s of each:
SL4A (with Touchqode):

Pros:
- Very easy to use and beginner friendly
- API documented on one easy-to-save page
- Samples provided
- Several languages and methods supported. You can even create a UI in HTML, with JavaScript used to hook into Android and/or any one of the scripting languages. Thus, you can launch an HTML UI from Python, then have the JavaScript call back to the Python or vice versa.
- Ability to compile your scripts into an installable, standalone APK (afterwards, on a PC utilising the Android SDK)
- Basic access to sensors, wifi, network, notifications, Intents, Dialog and Toasts
- Integrates perfectly with Touchqode for editing your scripts
Cons:
- No support for OpenGL. Can’t easily create games (perhaps only by using HTML5 in a WebView).
- Support for Activities (full screen user interface) is experimental. Not easy to create standard-looking apps utilising Activies and ListViews, or even just 2D surfaces.
- UI will mostly be dialog based (which is not necessarily a bad thing)
Ruboto IRB:

Pros:
- Quick and easy to use, also beginner-friendly
- Many samples provided that can be used to hack together your app
- Ruby code is concise and elegant
- Powerful access to full Android API. You can create Activities, use ListViews, etc. Infact, one of the samples is actually a re-implementation of some parts of the Android API Demos app, including OpenGL and 2D drawing!
- Your code uses standard Android API, meaning you learn the Android SDK as you code
- IRB console allows you to code interactively and use explorative programming
Cons:
- Only Ruby is supported
- Not integrated with external editors, so you can’t easily use Touchqode for code editing
- You will need the Android SDK documentation handy (offline)
Setting up:
Here’s how to set up before going on your holiday. Go to the Android Market and install these:
- Ruboto IRB
- Touchode
- Learning Python (if you would like to)
- Install the latest unofficial SL4A from: http://code.google.com/p/android-scripting/wiki/Unofficial. Don’t worry about the Honeycomb remix at the bottom, as it doesn’t support Fullscreen UI yet.
- Go to http://code.google.com/p/android-scripting/ and install the scripting languages you would like (e.g. Python)
- Save the API reference page for offline reference (using Opera Mobile Saved Pages, for example): http://code.google.com/p/android-scripting/wiki/ApiReference
- You may also want to save some of the Android API documentation for offline use. Or work through a book with example code, etc.
That’s it! Now let’s see how we use these.
Quick start:
Ruboto IRB:
- Simply start the app and it will start with the Irb tab. Here you can experiment interactively, for example, try this:
android.widget.Toast::makeText($activity, “test”, 1).show
- Click the Scripts tab, select demo-android-api.rb. The code will load in the Editor.
- Click the menu drop down, and select Execute. You will see a subset of the Api Demos app implemented using Ruboto.
- Peruse the sample code to see how simple it is, then start hacking away.
SL4A with Touchqode:
- Start the SL4A app
- You should see samples of scripts for the languages you installed, e.g. Python. Click any script and click the edit icon (pencil).
- Use Touchqode to open the file (make it default if you like).
- In Touchqode, press menu > Save & Execute
- Select to run it in Scripting Layer (you can make it default) and your script will execute. You can also execute HTML files this way (or directly from SL4A by clicking the cogs icon).
- Copy and paste the example at the bottom of this page into a file, e.g. fullscreen_ui.py: http://code.google.com/p/android-scripting/wiki/FullScreenUI
- Execute this to see how you can create Android UI using Python.
- Peruse the sample code and the API reference, then hack away.
That should get you started on some scripting and Android hacking. Feel free to chat and post your scripts on our forum (see link above). Happy hacking, Merry Christmas, and Happy New Year!
You can also try to use DroidDevelop with JavaIDEDroid.
Whis program use JavaIDEDroid for compile projects and have some improves for make it more quikly and easy.
Wow… this is really good. I don’t see myself doing any of this as I don’t consider coding fun anymore. But thank you for making me like dev again.