Porting J2ME Apps to Nokia X Using J2ME Android Bridge

download Porting J2ME Apps to Nokia X Using J2ME Android Bridge

of 11

description

Porting J2ME Apps to Nokia X Using J2ME

Transcript of Porting J2ME Apps to Nokia X Using J2ME Android Bridge

  • Porting J2ME apps to Nokia X using J2ME Android Bridge v0.1, Cao Phong

    1. Introduction 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 youre allowed to add your own adapters (for example integrating Nokia X services). Remember that youre always encouraged to submit your work to the repository so that others can re-use.

    2. Limitations and known issues Limitations: some classes are still missing or dont have enough methods. However, the framework allows you to easily implement anything you need. Known issues:

    1. The anchor point for positioning the image in drawImage method must not be 0 (for example, using Graphics.LEFT | Graphics.TOP instead of 0)

    2. If you encounter screen flicker issues, replace GameCanvas by Canvas and move all of your updating and rendering methods to paint method:

    public void paint(Graphics g) { GameUpdate(); GameRender(g); }

    3. showNotify method isnt invoked when you first launch the app so avoid doing any initialization/loading here

    4. Create instance of Canvas/GameCanvas class in midlet constructor may cause exception.

    3. Preparation 1. Setting up the development tools for Nokia X by installing:

    Android Developer Tools (ADT) Bundle including Eclipse IDE Nokia X services SDK Environment setup in this guide

    2. Download J2ME Android Bridge 0.2.1 and extract it to any folder 3. 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.

  • 4. Have a look at the instructions from the original site to know how to submit your changes to the J2AB repository: https://www.assembla.com/spaces/j2ab/wiki/Converting_From_J2ME

    4. 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:

    1. Fixing bugs related to the wrapper APIs (be aware of the known issues section above) 2. Adapting UI for Nokia X device. Your J2ME project mostly supports lower screen sizes

    (i.e. 240x320) so youll need to update your graphics and code to work on 480x800 resolution.

    3. Update device specific APIs: input, orientation, media 4. Integrating Nokia X services such as Nokia In-app Billing, HERE map or Notification APIs

    for your need.

    5. Tested projects These J2ME projects have been tested with J2AB and take less than 30 minutes to build the first runnable version on Nokia X device:

    sudokumaster-jme: https://github.com/nokia-developer/sudokumaster-jme drumkit-jme: https://github.com/nokia-developer/drumkit-jme battle-tank: https://github.com/nokia-developer/battle-tank racer: https://github.com/nokia-developer/racer gems-asha: http://1drv.ms/1gORk8S