Android Beyond Java: Part Two
This series of posts highlights a number of other languages and toolkits for developing Android applications, beyond the standard Java-based SDK. These are a preview of topics to be covered in CommonsWareâ€™s upcoming book â€œAndroid Beyond Javaâ€, to be released in 2010.
Scripting languages for Android come in two forms: ones that run via their own activity, and ones that are designed to be embedded in another application.
The most visible example of the former is the Android Scripting Environment (ASE), which offers you the ability to write scripts in “Python, Perl, JRuby, Lua, BeanShell, and shell”. Some of these, notably Python and Perl, are achieved through ports of their C-based interpreters, rather than via JVM versions of the langauge (e.g., Jython). Through some ingenious RPC mechanisms, these C-based interpreters still have access to Android APIs, as wrapped by the ASE environment itself.
However, in some cases, you may wish to embed an interpreter in your own application, for user scripts or the like. Here, interpreters once again come in two flavors: those that try to generate JVM bytecodes on the fly, and those that don’t.
Those that try to generate JVM bytecodes on the fly will have problems with Android, because Android does not execute JVM bytecodes. Android executes Dalvik VM bytecodes, and the JVM->Dalvik conversion happens in the development environment, not on the device. Hence, these languages either need a mode to disable such bytecode-generation optimizations, or they need to be taught how to create Dalvik VM bytecodes as an option.
Some languages that fit this pattern include:
- JRuby: JRuby has been demonstrated to run on Android, though not yet as an embedded language.
- Jython: An early attempt to get Jython working with Android appears to be abandoned.
- Groovy: There has been some work done in the summer of 2009 to get Groovy working on Android.
Other languages, like BeanShell, do not attempt to generate JVM bytecodes, and therefore work quite nicely on Android. However, watch out for old JARs. In the case of BeanShell, the JARs up on the official site were compiled with Java 1.4.2, which does not work with Android. Recompiling the code under a newer Java compiler clears up that problem.
If you are aware of other scripting languages, embeddable or otherwise, that work on Android, post them in the comments!
Next Post: The NDK
You might also like
MyTouch 4G Coming November 3rd The phone announcements and rumors have been coming fast and furious lately, and T-Mobile just threw their hat in the ring too. CNET is reporting
Today’s the long-anticipated day that the Motorola Droid Bionic hit Verizon shelves around the country. Officially announced just yesterday, the new hotness will set you back a cool $300 with