Android Beyond Java: Part Two

toolsThis 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

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.
  • Rhino: This implementation of Javascript-on-Java at least used to work on Android when used in pure interpreter mode.
  • 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

About author

AndroidGuys
AndroidGuys 4642 posts

Founded on November 5, 2007, we've enjoyed bringing you the latest in Android news and rumors. Updated daily, we strive to deliver reviews, opinions, and updates on all things related to Android.

You might also like

News and Rumors

First Photos of Motorola Droid 2 Surface

We have heard about the rumored sequel to the Motorola Droid for quite sometime.  Now, thanks to the blog Droid-Life, we have pictures! As you can see from the image

News and Rumors

HTC Hero Shows Up

One of the HTC handsets leaked from early in the year has resurfaced.  The HTC Hero has shed the pink from the early look image and put on a more

News and Rumors

ADC2: Submit! Go! Now!

The Android Developer Challenge 2 is on! Read more in today’s episode of Building ‘Droids! Updated with new information!

12 Comments

    • commonsguy
      October 15, 20:56 Reply

      That's cool! I've added Kawa to my list of projects to track. So far, I haven't seen any public releases of anything from App Inventor, though.

      Thanks!

    • commonsguy
      October 15, 20:58 Reply

      On its own, it is just a Javascript library, AFAICT. For on-device applications, you might be able to use it in conjunction with PhoneGap or the equivalent (see yesterday's post).

      Thanks!

  1. patthoyts
    October 21, 08:17 Reply

    Hecl (http://www.hecl.org/) is a scripting language that is written in Java and supports Android and J2ME and is having work done to support Blackberry. It provides a command oriented language similar to Tcl and also provides access to the underlying Java libraries. So unlike ASE (last time I looked) which does not let you create a GUI, you can create Android graphical layouts with Hecl.

  2. tona
    January 08, 03:50 Reply

    very ggooooooooooooodddddddd

  3. campaign buttons
    May 24, 04:30 Reply

    It is a very useful article for the developers regarding a number of other languages and
    toolkits for developing Android applications, beyond the standard
    Java-based SDK. thanks for sharing.

  4. NABH
    May 28, 10:56 Reply

    I really appreciate your post and you explain each and every point very well.Thanks for sharing this information.And I’ll love to read your next post too.
    Regards:
    NABH

Leave a Reply