Every time a new open technology appears, independent developers attempt to integrate it with other technologies. Programmers are often eager to try new stuff out especially in areas where it was not designed to be used. There’s a lot of porting in all directions going on. By satisfying their curiosity they give everyone incredible innovations as a side effect.
When Google App Engine was released, there were immediately demands raised for support of other programming languages than Python. Developers wanted everything from Java and C# to Ruby and Scala.
Android is less than 6 months old, and just two weeks ago the great Android Developer Challenge was closed with more than 1700 submissions. Google achieved enormous interest in Android within the Java community. Not surprisingly, people started thinking about using other languages to develop apps on Android.
C/C++
Linux development in general is of course based on C and C++. Everything from kernel and its modules to windowed environments like GNOME and KDE to office applications is in most cases written in C/C++. The mobile world has also chosen C++ since it can provide best performance and memory usage what is so crucial in embedded environments. And since Android is in fact another Linux distro, an attempt of running native apps seems quite natural.
Aaron P. D’Souza described how to compile and run a tiny console program within emulator. Aaron used GNU/ARM Linux toolchain that can be downloaded here. Also Benno came up with similar solution.
Unfortunately, such native apps can’t access all the cool features that make Android so special, since they are accessible only through Java framework. If you want mix C++ and Java but still send SMS messages, capture video or use location based services, you may however try to use JNI. Davanum Srinivas presents how to achieve this step by step. This way one can make part of his app partially native to gain performance, for instance in case he uses some unique audio/video coding algorithms or advanced math, and call it from Java through JNI.
There is however a lot of doubt about these attempts. Even a discussion arose on Google Groups. One of main concerns is such native code has to be compiled for every device out there that is going to run Android to make it fully supported. And Android was created to eliminate the need to recompile stuff. Hatem Ben Yacoub of Open Handset Magazine has addressed the issue here.
Python, Jython
There are some python scripts like activityCreator.py included within Android SDK. Moreover, we all know Python, along with Java, to be one of the most used languages by Google engineers. So, is it possible to write Python apps for Android?
First attempts of installing and running python snippets took Marcelo Barros de Almeida but he couldn’t get it running. There is of course a problem that, just like native apps, such scripts couldn’t use all the features without creating special bindings to Android API first.
Jython might be of help here, allowing to run Python scripts within JVM (or rather Dalvik VM) and transparently access API. hdante tried to use Jython on Android but it also appeared difficult.
Google used Apache Harmony project that reimplements all Java standard APIs. Unfortunately, Harmony hasn’t complete implementation of Java reflection and there are java.beans.IntrospectionException thrown.
Ruby, JRuby and Groovy
The very same problem appears in repect to Ruby and JRuby. Also James Williams tried to bring Groovy to Android with no success. Here is some discussion.
Scala
It seems the only team to get a “foreign” language run on Android are the Scala guys. They even made a dedicated Android Target for their technology. There is a short description on how to get a Scala snippet running in the emulator.
Other BIG players
Sun must be quite worried Google thrown away their J2ME and made their own solution (Dalvik). Just as Sun tries a lot to get J2ME running on iPhone, we could wonder if they are going to try introducing JavaFX Mobile to Android in the future. Is Adobe going to make sure Flash runs in Android?
.NET and Mono communities are considering workarounds to allow running their code on Google’s OS. Here are some ideas by now.
Google Gears and JavaScript
Google Gears brings the opportunity to develop desktop-like applications in JavaScript. Combined with GWT and run within Android’s WebKit browser, it could grow in time to become another app platform. And since all modern handheld devices are equipped with AJAX-capable browsers, Gears+GWT tandem could let us create applications that run on more than Android: including iPhone, Windows Mobile and Symbian-based phones. There are successful attempts in bringing GWT to Android. Gears in mobile world is currently ported to Windows Mobile only but we can be pretty sure we shall see it in WebKit based browsers too. There are rumors that porting Gears to Safari has been already started.
Gears open up possibilities to use Dojo, JQuery, YUI, GWT and many more. It would also allow us to reuse code of our existing AJAX-enabled web apps straight into mobile version, thus reducing significantly its implementation time.
What about J2ME?
A frequent question that appears on various forums is how to run J2ME applications on Android. Since Android itself does not support Java ME, there are attempts to fill the gap. ME4SE is a project that aims to supplement SE with ME so J2ME software could be run in J2SE environment. Poliplus created ME4android that allows to port your J2ME application to Android.
Conclusion
Android uses Dalvik VM instead of JVM. Dalvik bytecode is incompatible with Java bytecode. It makes impossible to implement dynamic Class Loaders known in web development. For instance iJetty (Jetty port to Android) cannot load .war-packaged web apps on the fly. Apache Harmony isn’t complete yet and since Android uses it, there are some significant problems so far. This all makes quite hard to port other languages and technologies to Android, though it is widely described to be noting but Linux and Java. This issues are said to be fixed soon but by that time any attempts to use other languages on Android may be impossible to succeed. It seems we are bound to Java for some time, we can give Scala a try or even start thinking about Gears. Gears could be in future the real “write-once-run-everywhere” solution, assuming of course that this “dream” is possible after all.
Some of the links I posted here are months old, so things might have changed by now. If anyone succeeded in porting other languages to Android, please let us know in comments.
Filed under: Articles | Tagged: ajax, android, api, c++, google, google gears, groovy, java, javascript, jni, jruby, jython, python, ruby, scala, sdk

In fact this is a proof that Scala is the most compatible “other programming language for jvm”.
[...] étant, Android est-il lui-même à l’abri d’une fragmentation ? Tagged as: Android, java, [...]
“One of main concerns is such native code has to be compiled for every device out there that is going to run Android to make it fully supported.”
Of course they could always use LLVM. It has a language-agnostic bytecode and a JIT compiler.