Saturday, May 16, 2009

LWUIT running on Android

This time I'd like to show how advanced Java ME applications can be easily converted to the Android. As an example I took LWUIT Demo and below here it is video that I captured from the emulator. For conversion I followed almost the same process as it was previously described in Running Java ME applications on Android article.

Similar work has already been done for iPhone, but only for that jailbroken ones. More information is available here.

27 comments:

  1. Where can I download the lwuit demo

    Can you please add link to apk file that we can test it

    ReplyDelete
  2. u can use the apk converter.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. To get Apk
    step1:- get jad and jar for LWUITDemo
    Go to -->https://lwuit.dev.java.net/servlets/ProjectProcess?tab=1

    step2:- To convert the MIDlet's into apk, go to --
    http://netmite.com/android/srv/1.6/getapk.php

    and choose second option and then save the generated apk file.

    Hope that helps..I just did it..
    For more stuff go to
    sites.google.com/site/vikantbains

    enjoy Droid :)

    ReplyDelete
  5. Vikrant Bains, netmite is a different product which offers easy conversion tool but it is not free if you want to distribute your converted application. MicroEmulator is also an open source project.

    ReplyDelete
  6. btw I see you judiciously have skipped the transitions part of the demo ? It's too slow for that I guess ? I am used to using LWUIT for developing MIDlets and if I look at the animations it's all running very slow...

    ReplyDelete
  7. TiGeR,

    LWUIT transitions are implemented using JSR-184. This JSR is only available as commercial extension for MicroEmulator. Contact me via email (microemu at gmail.com) if you are interested in licensing.

    ReplyDelete
  8. sorry Bartek not in this moment of time, we might be going to develop for Android in the near future but there are no real plans for that... I was just mentioning what I noticed :D

    ReplyDelete
  9. Hi,

    I try to run javame LWUIT application on Android emulator but it's failed.

    - Helloworld application with LCDUI Form runs without problem
    - Helloworld application with LWUIT Form doesn't run
    - LWUIT-Demo doesn't run too
    The error is the following: "The application UIDemoMIDlet (process org.microemu.android.com.sun.lwuit.uidemo.UIDemoMIDlet) has stopped unexpectedly. Please try again."

    LWUIT-Demo is compiled with Netbeans and runs on emulator devices.
    LWUIT-Demo.apk is generated with micoremu-android ant script, and install with "adb install LWUIT-Demo.apk".

    Please, could you help me please.
    Thank you very much

    Juien_m

    ReplyDelete
  10. Hi,

    I try to run javame application on Android emulator but it's failed.

    - Helloworld application with LCDUI Form runs without problem
    - Helloworld application with LWUIT Form doesn't run
    - LWUIT-Demo doesn't run too
    The error is the following: "The application UIDemoMIDlet (process org.microemu.android.com.sun.lwuit.uidemo.UIDemoMIDlet) has stopped unexpectedly. Please try again."

    LWUIT-Demo is compiled with Netbeans and runs on emulator devices.
    LWUIT-Demo.apk is generated with micoremu-android ant script, and install with "adb install LWUIT-Demo.apk".

    Please, could you help me please.
    Thank you very much

    Juien_m

    ReplyDelete
  11. Hi,

    I try to run javame application on Android emulator but it's failed.

    - Helloworld application with LCDUI Form runs without problem
    - Helloworld application with LWUIT Form doesn't run
    - LWUIT-Demo doesn't run too
    The error is the following: "The application UIDemoMIDlet (process org.microemu.android.com.sun.lwuit.uidemo.UIDemoMIDlet) has stopped unexpectedly. Please try again."

    LWUIT-Demo is compiled with Netbeans and runs on emulator devices.
    LWUIT-Demo.apk is generated with micoremu-android ant script, and install with "adb install LWUIT-Demo.apk".

    Please, could you help me please.
    Thank you very much

    Juien_m

    ReplyDelete
  12. juien_m,

    What does logcat say? Any exception thrown?

    ReplyDelete
  13. Bartek,

    Where can I found log file?

    I've just the following error when I want to run the application on Android Emulator:

    "The application UIDemoMIDlet (process org.microemu.android.com.sun.lwuit.uidemo.UIDemoMIDlet) has stopped unexpectedly. Please try again."

    juien_m

    ReplyDelete
  14. juien_m,

    You need Eclipse SDK with Android plugin:
    http://developer.android.com/sdk/eclipse-adt.html

    or, use adb tool from Android SDK:
    http://developer.android.com/guide/developing/tools/adb.html

    ReplyDelete
  15. Bartek,

    I already use adb tool.

    ReplyDelete
  16. I'm also getting the same error. In my opinion can not convert LWUIT to APK !!!!
    Or if possible tell me how convert LWUIT ???? ! commercial non-profit ... DOES NOT WORK!

    ReplyDelete
  17. hayktsirunyan,

    What does logcat say? Any exception thrown?

    You need Eclipse SDK with Android plugin:
    http://developer.android.com/sdk/eclipse-adt.html

    ReplyDelete
  18. I use ADB ANDROID app for Windows , ADB INSTALL MYAPP.APK !. Always the same exception
    I remove all 3D transision...all remove ..no show FORM !

    "The application UIDemoMIDlet (process org.microemu.android.com.sun.lwuit.uidemo.UIDemoMIDlet) has stopped unexpectedly. Please try again."

    adb logcat *: W

    ReplyDelete
  19. W/dalvikvm( 575): Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Ly;
    W/dalvikvm( 575): threadid=13: thread exiting with uncaught exception (group=0x40015560)
    E/AndroidRuntime( 575): FATAL EXCEPTION: Thread-14
    E/AndroidRuntime( 575): java.lang.ExceptionInInitializerError
    E/AndroidRuntime( 575): at bd.a(Unknown Source)
    E/AndroidRuntime( 575): at bd.a(Unknown Source)
    E/AndroidRuntime( 575): at com.sun.lwuit.uidemo.UIDemoMIDlet.startApp(Unknown Source)
    E/AndroidRuntime( 575): at javax.microedition.midlet.MIDlet$MIDletAccessor.startApp(MIDlet.ja
    va:50)
    E/AndroidRuntime( 575): at org.microemu.android.MicroEmulator$3.run(MicroEmulator.java:206)
    E/AndroidRuntime( 575): at java.lang.Thread.run(Thread.java:1019)
    E/AndroidRuntime( 575): Caused by: java.lang.ExceptionInInitializerError
    E/AndroidRuntime( 575): at java.lang.Class.classForName(Native Method)
    E/AndroidRuntime( 575): at java.lang.Class.forName(Class.java:234)
    E/AndroidRuntime( 575): at java.lang.Class.forName(Class.java:181)
    E/AndroidRuntime( 575): at j.a(Unknown Source)
    E/AndroidRuntime( 575): at j.(Unknown Source)
    E/AndroidRuntime( 575): at bz.(Unknown Source)
    E/AndroidRuntime( 575): at y.(Unknown Source)
    E/AndroidRuntime( 575): at y.(Unknown Source)
    E/AndroidRuntime( 575): ... 6 more
    E/AndroidRuntime( 575): Caused by: java.lang.IncompatibleClassChangeError: aj
    E/AndroidRuntime( 575): at aj.(Unknown Source)
    E/AndroidRuntime( 575): ... 14 more
    W/ActivityManager( 61): Force finishing activity org.microemu.android.com.sun.lwuit.uidemo.UIDemo
    MIDlet/org.microemu.android.MicroEmulator
    W/InputManagerService( 61): Window already focused, ignoring focus gain of: com.android.internal.vi
    ew.IInputMethodClient$Stub$Proxy@40697530

    ReplyDelete
  20. hayktsirunyan,

    I think there should be also some important information in logs before the fragment that you attached.

    ReplyDelete
  21. Hi Bartek, I could get LWUITDemo apk and it runs on android emulator, but when I change the orientation (ctrl + F11), app crash :S. Logcat says first time I rotate:

    D/dalvikvm( 116): GC_EXPLICIT freed 2117 objects / 126144 bytes in 161ms
    I/WindowManager( 58): Setting rotation to 1, animFlags=1
    I/ActivityManager( 58): Config changed: { scale=1.0 imsi=310/260 loc=en_US tou
    ch=3 keys=2/1/1 nav=3/1 orien=2 layout=34 uiMode=17 seq=15}
    --------------
    ...and screen goes black...then I rotate again and logcat says:
    V/MicroEmulator( 411): An exception occurred during transition paint this might
    be valid in case of a resize in the middle of a transition
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): java.lang.ArrayIndexOutOfBoundsException
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): n at as.a(Unknown Source)
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): ) at y.f(Unknown Source)
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): ) at y.g(Unknown Source)
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): ) at y.b(Unknown Source)
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): ) at cg.run(Unknown Source)
    V/MicroEmulator( 411):
    V/MicroEmulator( 411): ) at java.lang.Thread.run(Thread.java:1096)
    V/MicroEmulator( 411):

    I have a midlet with lwuit and have the same problem with that. Any advice I would appreciate. Thanks!

    ReplyDelete
  22. NaveganteSilencioso,

    It is hard to say anything about the error when your application is obfuscated and all the classes and methods got cryptic names. Are you able to test the unobfuscated build?

    ReplyDelete
  23. Sorry, you're absolutly right, here it is:
    I/ActivityManager( 58): Config changed: { scale=1.0 imsi=310/260 loc=en_US tou
    ch=3 keys=2/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=22}
    I/WindowManager( 58): Setting rotation to 0, animFlags=0
    I/ActivityManager( 58): Config changed: { scale=1.0 imsi=310/260 loc=en_US tou
    ch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=23}
    D/dalvikvm( 473): GC_EXTERNAL_ALLOC freed 359 objects / 886072 bytes in 393ms
    D/dalvikvm( 473): GC_EXTERNAL_ALLOC freed 154 objects / 9600 bytes in 196ms
    D/dalvikvm( 473): GC_EXTERNAL_ALLOC freed 936 objects / 268248 bytes in 86ms
    V/MicroEmulator( 473): An exception occurred during transition paint this might
    be valid in case of a resize in the middle of a transition
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): java.lang.ArrayIndexOutOfBoundsException
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): n at com.sun.lwuit.animations.CommonTransitions.pa
    intAlpha(CommonTransitions.java:460)
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): ) at com.sun.lwuit.animations.CommonTransitions.pa
    int(CommonTransitions.java:423)
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): ) at com.sun.lwuit.Display.paintTransitionAnimatio
    n(Display.java:551)
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): ) at com.sun.lwuit.Display.edtLoopImpl(Display.jav
    a:656)
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): ) at com.sun.lwuit.Display.mainEDTLoop(Display.jav
    a:618)
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): ) at com.sun.lwuit.RunnableWrapper.run(RunnableWra
    pper.java:119)
    V/MicroEmulator( 473):
    V/MicroEmulator( 473): ) at java.lang.Thread.run(Thread.java:1096)
    V/MicroEmulator( 473):
    D/dalvikvm( 58): GC_EXPLICIT freed 1093 objects / 55944 bytes in 122ms
    .....
    Manifiest is:


    Thanks!

    ReplyDelete
  24. NaveganteSilencioso,

    It looks like a bug in the LWUIT library.

    ReplyDelete
  25. Hi, I try to run a Lwuit application but I'm getting this message: "The application amovil (process org.microemu.android.Interfaz.Amovil) has stopped unexpectedly. Please try again. Force close."
    This is the log:
    https://docs.google.com/document/d/10O1m0uriA-ddcaALWWwSl_VVcxqdnvyPrXcEeJPjOEw/edit
    So, I removed javax.microedition.media.Player and javax.microedition.media.control.VideoControl from com.sun.lwuit.impl.midp.GameCanvasImplementation, but when I try to run the application again it shows a black screen and this is the log:
    https://docs.google.com/document/d/1kfYsyuvQEq3Il9HwpEaJwW1JkDNEddvOd7-4DYvUDw8/edit
    I would really appreciate if you help me.
    Regards, Laura.

    ReplyDelete
  26. Laura,

    Did you manage to solve already your problem?

    ReplyDelete
  27. Hi...I have developed application using LWUIT 1.4.
    I have converted it using Microemulator.
    But on running the application in the emulator I am getting the error "The application has stopped unexpectedly"
    Pasted below is some part of the log
    "V/MicroEmulator( 417):
    E/dalvikvm( 417): Could not find class 'javax.microedition.media.Player', refer
    enced from method com.sun.lwuit.impl.midp.GameCanvasImplementation.createVideoCo
    mponent
    W/dalvikvm( 417): VFY: unable to resolve check-cast 570 (Ljavax/microedition/me
    dia/Player;) in Lcom/sun/lwuit/impl/midp/GameCanvasImplementation;
    D/dalvikvm( 417): VFY: replacing opcode 0x1f at 0x0001
    D/dalvikvm( 417): VFY: dead code 0x0003-0017 in Lcom/sun/lwuit/impl/midp/GameCa
    nvasImplementation;.createVideoComponent (Ljava/lang/Object;)Ljava/lang/Object;
    E/dalvikvm( 417): Could not find class 'javax.microedition.media.Player', refer
    enced from method com.sun.lwuit.impl.midp.GameCanvasImplementation.getMediaTime
    W/dalvikvm( 417): VFY: unable to resolve check-cast 570 (Ljavax/microedition/me
    dia/Player;) in Lcom/sun/lwuit/impl/midp/GameCanvasImplementation;
    D/dalvikvm( 417): VFY: replacing opcode 0x1f at 0x0000
    D/dalvikvm( 417): VFY: dead code 0x0002-0006 in Lcom/sun/lwuit/impl/midp/GameCa
    nvasImplementation;.getMediaTime (Ljava/lang/Object;)J
    E/dalvikvm( 417): Could not find class 'javax.microedition.media.Player', refer
    enced from method com.sun.lwuit.impl.midp.GameCanvasImplementation.getVideoContr
    ol

    E/AndroidRuntime( 417): FATAL EXCEPTION: Thread-12
    E/AndroidRuntime( 417): java.lang.VerifyError: com.sun.lwuit.impl.midp.GameCanv
    asImplementation
    E/AndroidRuntime( 417): at com.sun.lwuit.impl.ImplementationFactory.crea
    teImplementation(ImplementationFactory.java:69)
    E/AndroidRuntime( 417): at com.sun.lwuit.Display.init(Display.java:278)
    E/AndroidRuntime( 417): at MobileColours.Colours.startApp(Colours.java:2
    9)
    E/AndroidRuntime( 417): at javax.microedition.midlet.MIDlet$MIDletAccess
    or.startApp(MIDlet.java:50)
    E/AndroidRuntime( 417): at org.microemu.android.MicroEmulator$3.run(Micr
    oEmulator.java:211)
    E/AndroidRuntime( 417): at java.lang.Thread.run(Thread.java:1019)
    I/ActivityManager( 74): Displayed org.microemu.android.MobileColours.Colours/o
    rg.microemu.android.MicroEmulator: +1s861ms
    W/ActivityManager( 74): Force finishing activity org.microemu.android.Mobile
    Colours.Colours/org.microemu.android.MicroEmulator
    I/dalvikvm( 74): Jit: resizing JitTable from 1024 to 2048
    "

    It is a problem with the media classes I suppose.

    Can you please guide me. It is very urgent.

    Thanks in Advance,
    Amit

    ReplyDelete