J2ME Android Bridge (J2AB) is a set of bridging libraries for porting J2ME applications to run on Android with no changes to the J2ME code. You'll need the original J2ME source for the application you are trying to port since this isn't an emulator, such as MicroEmulator, but a set of adapters from the J2ME APIs to the Android APIs. The license is public domain so you’re allowed to add your own adapters (for example integrating Nokia X services). Remember that you’re always encouraged to submit your work to the repository so that others can re-use.
Limitations and known issues
- Some classes are still missing or don’t have enough methods. However, the framework allows you to easily implement anything you need.
- The anchor point for positioning the image in drawImage method must not be 0 (for example, using Graphics.LEFT | Graphics.TOP instead of 0)
- If you encounter screen flicker issues, replace GameCanvas by Canvas and move all of your updating and rendering methods to paint method:
- showNotify method isn’t invoked when you first launch the app so avoid doing any initialization/loading here
- Create instance of Canvas/GameCanvas class in midlet constructor may cause exception.
- Setting up the development tools for Nokia X by installing:
- Download J2ME Android Bridge 0.2.1 and extract it to any folder
- Check-out the latest source code from SVN and merge/update it to your J2AB project. This is important since you can find some new classes in javax.microedition.lcdui.game package from /trunk/j2ab_midpapi/src/main/java/javax/microedition/lcdui/game. Besides, you can also leverage on the bug fixes from many contributors.
- Have a look at the instructions from the original site to know how to submit your changes to the J2AB repository
Porting to Nokia X
Step 1: Open Eclipse, import j2ab_adapter project into your workspace:
Step 2: copy j2ab_midpapi folder to the default location of your workspace:
Step 3: copy your J2ME project to the default location of your workspace. Note that all source files must be put in src folder and resource files must be put in res folder:
Step 4: create a new Java project and name it j2ab_midpapi:
Step 5: create a new Java project and name it as your J2ME project:
Step 6: Open j2ab_midpapi properties and select Java Build Path. In Libraries tab, remove reference to the standard Java library (JRE). Then choose Add External JARs…, browse to android-sdk\sdk\platforms\android-16 and add android.jar library:
Step 7: repeat step 6 with your J2ME project
Step 8: open your J2ME project properties and select Java Build Path. In Projects and Order and Export tabs, add reference to j2ab_midpapi project:
Step 9: open J2ABMIDletActivity properties and select Java Build Path. In Projects and Order and Export tabs, add reference to the other two projects:
After this step, there should be no compilation error unless your project requires any missing API.
Step 10: this step is optional. If your J2ME app has any resource file, remember to copy them to assets folder of J2ABMIDletActivity project. After that, modify your source code using the correct loading path:
Step 11: In J2ABMIDletActivity project, open project.properties file to change the target to android-16:
Step 12: In J2ABMIDletActivity project, open jad.properties file to declare the midlet class name of your J2ME project:
Step 13: right-click on J2ABMIDletActivity project, select Run As > 1 Android Application and enjoy your app running on Nokia X emulator. :)
Additional steps: your app is now runnable on Nokia X emulator. These are the next steps that you still need to do:
- Fixing bugs related to the wrapper APIs (be aware of the known issues section above)
- Adapting UI for Nokia X device. Your J2ME project mostly supports lower screen sizes (i.e. 240x320) so you’ll need to update your graphics and code to work on 480x800 resolution.
- Update device specific APIs: input, orientation, media…
- Integrating Nokia X services such as Nokia In-app Billing, HERE map or Notification APIs for your need.
These J2ME projects have been tested with J2AB and take less than 30 minutes to build the first runnable version on Nokia X device: