Tuesday, November 4, 2008

Running Java ME applications on Android

Each new software platform, including Android, at the beginning is struggling with a small number of the available applications. This is why Google spent $10 million trying to attract developers to their Android Developer Challenge before G1 phone release. Taking advantage of an opportunity to run large number of existing Java ME applications may determine a significant value for the Android platform. This is also occasion for developers to reduce cost preparing mobile software for a smaller number of platforms at the same time. MicroEmulator, which is pure Java implementation of Java ME API's in Java SE, seems to be very well suited for the Android. Last few months I've been working extending MicroEmulator to be an executable environment to run Java ME applications on that platform. Here are results of my work with demonstration of popular Java ME game 5ud0ku automatically translated to the Android.

These are screenshots of 5ud0ku running side by side on emulators: Java ME and Android.

Works to complete the effort are not finished yet, but I hope a lot of existing Java ME applications can be already transformed to Android. At the moment code is only available in SVN repository. For anyone interested, here is the short manual how to convert 5ud0ku yourself:

1. Check out MicroEmulator from SVN repository

svn co https://microemulator.svn.sourceforge.net/svnroot/microemulator/trunk/microemulator microemulator -r 1997

2. Build MicroEmulator project using Maven

cd microemulator

3. Make sure that the following properties in microemu-android/build.xml correctly point to the Android SDK and ASM jar file

<property name="sdk-folder" value="$HOME/android-sdk-linux_x86-1.0_r1"/>
<property name="asm.jar" value="$HOME/asm/asm-3.1.jar"/>

4. Configure properties for 5ud0ku game, edit microemu-android/build.xml file (before you have to save 5ud0ku.jar in microemulator folder)

<property name="midlet.name" value="5ud0ku"/>
<property name="midlet.package" value="5ud0ku.apk"/>
<property name="midlet.icon" value="bin/assets/5ud0ku-icon.png"/>
<property name="midlet.class" value="de.wintermute.sudoku.SudokuMidlet"/>
<property name="midlet.jar" value="../5ud0ku.jar"/>

5. Create Android apk package with Ant

cd microemu-android

6. And finally deploy microemu-android/bin/5ud0ku.apk on emulator or G1 phone. For all of you who don't want to go through this somehow long procedure, here it is already prepared 5ud0ku.apk package.

UPDATE svn checkout command now include revision number

UPDATE Conversion manual has been updated, it is presented in Converting JavaME applications to the Android platform (revisited)