Wednesday, November 25, 2009

Converting JavaME applications to the Android platform (revisited)

It's been a year since I posted tutorial how to automatically convert Java ME MIDlets to Android platform. Since then, a lot of work has been done to make this tool even better and support more and more different Java ME applications and games. I've got a lot of positive feedback as well which also helped improving quality of this project.

Now, it is much simpler to set up MIDlet details, since only jad location and resulting apk package file name is necessary to provide in configuration.

For this demonstration procedure, I took a popular Java ME game 5ud0ku.






Required third party software:
- Java SE JDK (http://java.sun.com/javase/)
- Subversion client (http://subversion.tigris.org)
- Maven http://maven.apache.org/
- Ant (http://ant.apache.org/)
- Android SDK version 1.5 or later (http://developer.android.com/)
- ASM (http://asm.ow2.org/)

1. Check out MicroEmulator from Subversion repository (revision 2211)


svn co http://microemu.googlecode.com/svn/trunk/microemulator microemulator -r 2211


2. Build MicroEmulator project using Maven


cd microemulator
mvn


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="\java\android-sdk-windows"/>
<property name="asm.jar" value="\java\asm-3.2\lib\asm-3.2.jar"/>


4. Configure properties for 5ud0ku game, edit microemu-android/build.xml file (before you have to download 5ud0ku.jad and 5ud0ku.jar files to the same folder)


<property name="midlet.jad" value="\java\5ud0ku.jad"/>
<property name="midlet.package" value="5ud0ku.apk"/>


5. Create Android apk package with Ant


cd microemu-android
ant


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

121 comments:

Сыр Российский said...

>Check out revision 2211
don't you use svn tags?

Bartek Teodorczyk said...

Сыр Российский,

Project is actively developed on trunk. Revision 2211 was well tested, but more advanced users can try to work directly on trunk.

BR,
Bartek Teodorczyk

Arioch /BDV/ said...

Can MicroEmu be instegrated into Android ?

It would be greate to have Opera Mini on Android or OpenMoko or Maemo phones.

And not to make special converted apps, but just to seamlessly install and run JAR's.

O! they possibly would have to be recompiled to dx format, yet that is not anything new. Philips 755 phone also recompiled midlets on installation.

Bartek Teodorczyk said...

Arioch,

I'm not sure if it is possible to convert Java ME jar directly on device. The question is whether dx tool can be executed on device.

Other option could be creating a web service that automatically convert jar to apk on the server side.

BR,
Bartek Teodorczyk

TiGeR said...

Any idea if something like this exists for Maemo 5 ?

Bartek said...

TiGeR,

There was some activity in the past (around 2006) to port Java ME to the Maemo using MicroEmulator, but I'm sure it is a bit outdated right now. More info can be found at: http://www.microemu.org/maemo/

BR,
Bartek Teodorczyk

marcos said...

Hi all, I'm trying to convert a J2ME MIDP application to android apk following the instructions, and I've accomplished arrive to the ant phase, but now I get the next error executing dex:

[exec] UNEXPECTED TOP-LEVEL ERROR:
[exec] java.lang.OutOfMemoryError: Java heap space
[exec] at com.android.dx.ssa.SsaBasicBlock.(SsaBasicBlock.java:97)
[exec] at com.android.dx.ssa.SsaMethod.makeNewGotoBlock(SsaMethod.java:245)
[exec] at com.android.dx.ssa.SsaBasicBlock.insertNewSuccessor(SsaBasicBlock.java:426)
[exec] at com.android.dx.ssa.SsaConverter.edgeSplitSuccessors(SsaConverter.java:221)
[exec] at com.android.dx.ssa.SsaConverter.edgeSplit(SsaConverter.java:119)
[exec] at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:47)
[exec] at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:100)
[exec] at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:74)
[exec] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:269)
[exec] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
[exec] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
[exec] at com.android.dx.command.dexer.Main.processClass(Main.java:297)
[exec] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:276)
[exec] at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[exec] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:228)
[exec] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[exec] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[exec] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[exec] at com.android.dx.command.dexer.Main.processOne(Main.java:245)
[exec] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
[exec] at com.android.dx.command.dexer.Main.run(Main.java:139)
[exec] at com.android.dx.command.dexer.Main.main(Main.java:120)
[exec] at com.android.dx.command.Main.main(Main.java:87)

I'm using JAVA JDK 1.6.0_01

Can anybody help me ?
Thanks in advance...

marcos said...

Hi, the problem is solved yet, modifying dx.bat setting the call to java with javaOpts=-Xmx256M...

Thanks...

the-arioch said...

> if it is possible to convert Java ME jar directly on device.

Okay, you're right here.
What i meant, that JavaME and JavaSE apps become equal in rights.

AFAIK applets and midetts differ only in runtime libraries and metadata text files, which object to run.

So, for Android indeed, it is out of scope of MicroEmu to make jar's directly runnable in this OS.
But what the ideal goal, i think, is that dx or some market-like service treated applets and midlets with no difference, with equal ease and reliability.

the-arioch said...

funny. they say that N19 can run midlets w/o recompilation with dx

Does it mean that N19 has two JVMs inside - Android's VM and some usual JME VM specially for midlets ?

http://www.amazines.com/article_detail.cfm/1266777?articleid=1266777

BUZZ said...

I converted apk form jad but can't install on devide.
My files are:
http://www.4shared.com/file/193816089/a8647348/DABMB.html

I don't know why error.
Please convert DABMobileBanking.jad to DABMobileBanking.apk for me.

Thanks and regards.

Bartek Teodorczyk said...

BUZZ,

Contact me on my email (barteo at gmail.com), I'll try to help you to resolve your problem with converting MIDlet.

BR,
Bartek Teodorczyk

Naveen said...

Hello, how can i download sub version ? In the site you have given i get an error saying there s no project named subversion.
Kindly help me in this regard.. Thanks ..

Bartek Teodorczyk said...

Naveen,

There was an error in link, now it is corrected. Just in case, I repeat it now: http://subversion.tigris.org/

BR,
Bartek Teodorczyk

Naveen said...

Hi,
When I was trying to build with maven I am getting error saying build failure.
See this screenshot i have uploaded.
See this

Bartek Teodorczyk said...

Naveen,

It sounds like you didn't correctly checked out source code from repository (the "svn co" command). On your machine there is no pom.xml file in microemulator folder.

BR,
Bartek Teodorczyk

k said...

I have checked out the latest version 2304 and tried it with my j2me app. Android 1.6 gives an unexpected error, 2.0 and 2.1 work fine! Also the 2.0 emulator with wvga scales up my screen (midlet thinks the size is 320x508). Any ideas what wrong?

Thanks Kleo

Bartek Teodorczyk said...

Kleo,

Can you provide a full stack trace from your crash on Android 1.6?

k said...

I/ActivityManager( 52): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.microemu.android.com.planarsoft.mobile.bar.Init/org.microemu.android.MicroEmulator }
I/ActivityManager( 52): Start proc org.microemu.android.com.planarsoft.mobile.bar.Init for activity org.microemu.android.com.planarsoft.mobile.bar.Init/org.microemu.android.MicroEmulator: pid=198 uid=10022 gids={3003, 1015}
D/dalvikvm( 30): GC freed 285 objects / 10872 bytes in 124ms
D/dalvikvm( 30): GC freed 50 objects / 2216 bytes in 109ms
D/dalvikvm( 30): GC freed 2 objects / 48 bytes in 83ms
V/ME(198): implementation registered [org.microemu.cldc.file.FileSystem]
V/ME(198):
W/dalvikvm( 198): Found field 'a', but sig is 'Lbk;' not 'Ljavax/microedition/midlet/MIDlet;'
D/dalvikvm( 198): DexOpt: couldn't find static field
W/dalvikvm( 198): VFY: unable to resolve static field 473 (a) in Lcom/planarsoft/j2me/service/b;
W/dalvikvm( 198): VFY: rejecting opcode 0x69 at 0x0013
W/dalvikvm( 198): VFY: rejected Lcom/planarsoft/mobile/bar/Init;.startApp ()V
W/dalvikvm( 198): Verifier rejected class Lcom/planarsoft/mobile/bar/Init;
W/dalvikvm( 198): Class init failed in newInstance call (Lcom/planarsoft/mobile/bar/Init;)
V/ME(198): error Message: Error starting MIDlet: Unable to create MIDlet, java.lang.VerifyError: com.planarsoft.mobile.bar.Init java.lang.VerifyError: com.planarsoft.mobile.bar.Init
V/ME(198):
V/ME(198): java.lang.VerifyError: com.planarsoft.mobile.bar.Init
V/ME(198): at java.lang.Class.newInstanceImpl(Native Method)
V/ME(198): at java.lang.Class.newInstance(Class.java:1472)
V/ME(198): at org.microemu.app.Common.loadMidlet(Common.java:418)
V/ME(198): at org.microemu.app.Common.initMIDlet(Common.java:1054)
V/ME(198): at org.microemu.android.MicroEmulator.onCreate(MicroEmulator.java:173)
V/ME(198): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
V/ME(198): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
V/ME(198): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
V/ME(198): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
V/ME(198): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
V/ME(198): at android.os.Handler.dispatchMessage(Handler.java:99)
V/ME(198): at android.os.Looper.loop(Looper.java:123)
V/ME(198): at android.app.ActivityThread.main(ActivityThread.java:4203)
V/ME(198): at java.lang.reflect.Method.invokeNative(Native Method)
V/ME(198): at java.lang.reflect.Method.invoke(Method.java:521)
V/ME(198): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
V/ME(198): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
V/ME(198): at dalvik.system.NativeStart.main(Native Method)
V/ME(198): destroyMIDletContext
V/ME(198):
D/AndroidRuntime( 198): Shutting down VM

k said...

and continues to this
W/dalvikvm( 198): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
E/AR(198): Uncaught handler: thread main exiting due to uncaught exception
E/AR(198): java.lang.RuntimeException: Unable to resume activity {org.microemu.android.com.planarsoft.mobile.bar.Init/org.microemu.android.MicroEmulator}: java.lang.NullPointerException
E/AR(198): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2851)
E/AR(198): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2866)
E/AR(198): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)
E/AR(198): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
E/AR(198): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
E/AR(198): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AR(198): at android.os.Looper.loop(Looper.java:123)
E/AR(198): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AR(198): at java.lang.reflect.Method.invokeNative(Native Method)
E/AR(198): at java.lang.reflect.Method.invoke(Method.java:521)
E/AR(198): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AR(198): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AR(198): at dalvik.system.NativeStart.main(Native Method)
E/AR(198): Caused by: java.lang.NullPointerException
E/AR(198): at org.microemu.MIDletBridge.getMIDletAccess(MIDletBridge.java:119)
E/AR(198): at org.microemu.android.MicroEmulator.onResume(MicroEmulator.java:197)
E/AR(198): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1225)
E/AR(198): at android.app.Activity.performResume(Activity.java:3560)
E/AR(198): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2838)
E/AR(198): ... 12 more
I/Process ( 52): Sending signal. PID: 198 SIG: 3
I/dalvikvm( 198): threadid=7: reacting to signal 3
E/dalvikvm( 198): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

Bartek Teodorczyk said...

Kleo,

Dalvik VM has some limitations when code is obfuscated. It is explained in: http://code.google.com/p/android/issues/detail?id=2422

I may suggest tune obfuscator parameters.

Zandaa said...

Hey, great work on the Micro Emulator.. However, I am trying to run my own Java ME Midlet on it, which we have to develop for a school project. The problem is that when I use a fillArc instruction it would run normally on the Java ME Emulator within NetBeans and on other phones that natively support it, however with the repackaged Android one I get that the arc is vertically flipped :\ any ideas?

Bartek Teodorczyk said...

Zandaa,

Sounds like a bug in MicroEmulator. For the technical discussion, let's move to the groups: http://groups.google.com/group/microemulator-support

Please tell me more details whether the arc is flipped or rotated by 180 degrees.

Tobias said...

Hi,

i have some problems with your Step 5. If i try to create the .apk i got 40 errors. I dont know what i can do. Can you help me? :)

here are my errors: Error Output (www.geratzt.de/microemu/erroroutput.txt)

I hope you can help me! Thx!!!

Bartek Teodorczyk said...

Tobias,

It looks that you have an error in pointing to the asm.jar. Correct the asm location in property:

<property name="asm.jar" value="\java\asm-3.2\lib\asm-3.2.jar"/>

lorydi said...

Hello,

I'm trying to get an .apk and while compiling I get an error:

Can not find simbol : android.R.styleable.Theme

Can you please help?

Thanks

Tobias said...

Thanks a lot, now it works great!!! :)

Bartek Teodorczyk said...

lorydi,

In which step of conversion do you get that error?

Mark Gillespie said...

Tried to convert the Forumla One Live Timings app to Android using this, got it to complile, but he app crashes :-(

See my post here:

http://androidforums.com/android-applications/52861-formula-1-timings-app.html#post431723

The original J2ME files are here:

http://mobile.formula1.com/download/select

Can you help/advise?

Bartek Teodorczyk said...

Mark,

The problem that you experience is due Java incompatibilities between Java ME VM and Dalvik VM. I'm aware of that problem and currently in progress of making a fix. Try to reach me in two or three weeks, most likely it will be fixed then.

Mark Gillespie said...

Many thanks, i'll keep track of things, as I am quite hopeful one this is worked out, it may indeed work, as I just tried out MicroEmulator on PC and it ran the app just fine..

http://i44.tinypic.com/2v2bpls.png

Matthias said...

Hello Bartek

The tutorial is great and I can compile the demo apps. However, I'm struggling with my own jar which is around 450KB.

I set in the dx.bat to javaOpts=-Xmx2048M

And it still produces the following error:

[exec] warning: Ignoring InnerClasses attribute for an anonymous inner clas
s that doesn't come with an associated EnclosingMethod attribute. (This class wa
s probably produced by a broken compiler.)
[exec]
[exec] UNEXPECTED TOP-LEVEL ERROR:
[exec] java.lang.OutOfMemoryError: Java heap space
[exec] at com.android.dx.ssa.SsaMethod.makeNewGotoBlock(SsaMethod.java:
245)
[exec] at com.android.dx.ssa.SsaBasicBlock.insertNewSuccessor(SsaBasicB
lock.java:426)
[exec] at com.android.dx.ssa.SsaConverter.edgeSplitSuccessors(SsaConver
ter.java:221)
[exec] at com.android.dx.ssa.SsaConverter.edgeSplit(SsaConverter.java:1
19)
[exec] at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConvert
er.java:47)
[exec] at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:100)
[exec] at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:74)
[exec] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslato
r.java:269)
[exec] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.ja
va:131)
[exec] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.jav
a:85)
[exec] at com.android.dx.command.dexer.Main.processClass(Main.java:297)

[exec] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:
276)
[exec] at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[exec] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.jav
a:228)
[exec] at com.android.dx.cf.direct.ClassPathOpener.processArchive(Class
PathOpener.java:245)
[exec] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPath
Opener.java:130)
[exec] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpe
ner.java:108)
[exec] at com.android.dx.command.dexer.Main.processOne(Main.java:245)
[exec] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:1
83)
[exec] at com.android.dx.command.dexer.Main.run(Main.java:139)
[exec] at com.android.dx.command.dexer.Main.main(Main.java:120)
[exec] at com.android.dx.command.Main.main(Main.java:87)

BUILD FAILED
D:\WORKSP~1\MICROE~1\MIB9E5~1\build.xml:211: exec returned: 3

Total time: 42 seconds

Bartek Teodorczyk said...

Matthias,

That's strange. I've been able to convert many jars around 1MB having increased heap memory only to 256M. Maybe, double check whether your javaOpts=-Xmx2048M is taken into account.

sonic said...

http://www.dashandyticket.de/portals/download/1/1.0/49/dasHandyTicket.jar

gives

E/AndroidRuntime( 1027): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 1027): java.lang.ClassCastException: org.microemu.android.device.ui.AndroidListUI$AndroidListAdapter$ViewHolder
E/AndroidRuntime( 1027): at org.microemu.android.device.ui.AndroidListUI.getString(AndroidListUI.java:108)
E/AndroidRuntime( 1027): at javax.microedition.lcdui.List.getString(List.java:139)
E/AndroidRuntime( 1027): at ao.commandAction(Unknown Source)
E/AndroidRuntime( 1027): at org.microemu.android.device.ui.AndroidListUI$AndroidListView.onKeyDown(AndroidListUI.java:232)
E/AndroidRuntime( 1027): at android.view.KeyEvent.dispatch(KeyEvent.java:1037)
E/AndroidRuntime( 1027): at android.view.View.dispatchKeyEvent(View.java:3683)
E/AndroidRuntime( 1027): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
E/AndroidRuntime( 1027): at android.widget.ListView.dispatchKeyEvent(ListView.java:1943)
E/AndroidRuntime( 1027): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
E/AndroidRuntime( 1027): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
E/AndroidRuntime( 1027): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
E/AndroidRuntime( 1027): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1655)
E/AndroidRuntime( 1027): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
E/AndroidRuntime( 1027): at android.app.Activity.dispatchKeyEvent(Activity.java:2038)
E/AndroidRuntime( 1027): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1631)
E/AndroidRuntime( 1027): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2368)
E/AndroidRuntime( 1027): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2338)
E/AndroidRuntime( 1027): at android.view.ViewRoot.handleMessage(ViewRoot.java:1641)
E/AndroidRuntime( 1027): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1027): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1027): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 1027): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1027): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 1027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 1027): at dalvik.system.NativeStart.main(Native Method)

sonic said...

I fixed it by replacing

return (String) listAdapter.getItem(elementNum);

with

return listAdapter.getItem(elementNum).toString();

but now:

Uncaught handler: thread main exiting due to uncaught exception
java.lang.IllegalArgumentException
at javax.microedition.lcdui.TextField.setString(TextField.java:156)
at javax.microedition.lcdui.TextField.setString(TextField.java:142)
at ai.b(Unknown Source)
at ai.commandAction(Unknown Source)
at org.microemu.android.device.ui.AndroidListUI$AndroidListView.onItemClick(AndroidListUI.java:246)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3285)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)

Bartek Teodorczyk said...

sonic,

I just fixed that ClassCastException problem and commited to repository.

I'd like to encourage you to use our ticketing system for reporting that kind of issues: http://code.google.com/p/microemu/issues/list

For discussions we have also two groups: http://groups.google.com/group/microemulator-support and http://groups.google.com/group/microemulator-developers

Bartek Teodorczyk said...

sonic,

Your IllegalArgumentException at TextField.setString(..) is thrown because text exceeds the current maximum capacity

Mark Gillespie said...

Will this fix the F1 timing app problem? If not do you have details of the problem so I can watch for a svn comit

Broiler said...

Hello Bartek. First I have to thank for your great work on miroemu!

I tried to "convert" my javame-files to .apk as you descripted. After an hour of configuration ant compiled my .apk :)

If i install the .apk in android-(2.0.1) my app starts as expected. If the app tries to show an midp-alert microemu throws an exception:

D/AndroidRuntime( 248): Shutting down VM

W/dalvikvm( 248): threadid=3: thread exiting with uncaught exception (group=0x4001b188)

E/AndroidRuntime( 248): Uncaught handler: thread main exiting due to uncaught exception

E/AndroidRuntime( 248): java.lang.NullPointerException

E/AndroidRuntime( 248): at org.microemu.android.device.ui.AndroidAlertUI.isToastable(AndroidAlertUI.java:105)

E/AndroidRuntime( 248): at org.microemu.android.device.ui.AndroidAlertUI.showNotify(AndroidAlertUI.java:170)

E/AndroidRuntime( 248): at javax.microedition.lcdui.Displayable.showNotify(Displayable.java:281)

E/AndroidRuntime( 248): at javax.microedition.lcdui.Display$1.run(Display.java:513)

E/AndroidRuntime( 248): at org.microemu.device.ui.EventDispatcher$ShowNotifyEvent.run(EventDispatcher.java:246)

E/AndroidRuntime( 248): at android.os.Handler.handleCallback(Handler.java:587)

E/AndroidRuntime( 248): at android.os.Handler.dispatchMessage(Handler.java:92)

E/AndroidRuntime( 248): at android.os.Looper.loop(Looper.java:123)

E/AndroidRuntime( 248): at android.app.ActivityThread.main(ActivityThread.java:4338)

E/AndroidRuntime( 248): at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime( 248): at java.lang.reflect.Method.invoke(Method.java:521)

E/AndroidRuntime( 248): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)

E/AndroidRuntime( 248): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

E/AndroidRuntime( 248): at dalvik.system.NativeStart.main(Native Method)

I/Process ( 61): Sending signal. PID: 248 SIG: 3

I/dalvikvm( 248): threadid=7: reacting to signal 3

E/dalvikvm( 248): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

What can is do? If you need more info i can send you sources and logs ...


Greets
Stefan

P.S. My app runs in your jnlp-tool without errors.

Bartek Teodorczyk said...

Broiler,

This has been fixed just now and commited to the repository.

I'd like to encourage you to use our ticketing system for reporting that kind of issues: http://code.google.com/p/microemu/issues/list

For discussions we have also two groups: http://groups.google.com/group/microemulator-support and http://groups.google.com/group/microemulator-developers

sonic said...

Thanks for the fast fix, unlike mine it even worked. I just bought a "HandyTicket" for the public transport here around Nürnberg :-)

I will post the remaining Exception via the ticketing system.

Broiler said...

Thank you! But looks like i can provide you with some more bugs on your bugtracker :|

Relating to your blogpost:
Maybe the Android-SDK-Folder in microemu-android/build.xml changed from
"{sdk-folder}/platforms/android-1.6"
to
"{sdk-folder}/platforms/android-6" with the latest SDK.

Broiler said...

I have submitted some issus i found on testing your great peace of software with my javame-project.
There is a annoying bug on List, found only running mircoemu running on Android.
http://code.google.com/p/microemu/issues/detail?id=39
Can you please have a look at it?
Greetings,
Broiler

Mark Gillespie said...

Hi Bartek, do you have a bug ID for the problems that's preventing the F1 Application running?

I would like to keep an eye out for when it's fixed, rather than just randomly doing "svn update" and trying things out every time there is a commit :-)

Many Thanks!

k said...

Safe obfuscation settings-

Hello,

a while ago i had a problem running my obfuscated j2me app on android < 2.0, because of a bug in android < 2.0 where 'class files are not allowed to contain fields with the same name but different types'.

The settings (proguard) below fix this problem

-keep public class com.mymainclass {
public *;
}

-dontpreverify
-dontoptimize
-dontusemixedcaseclassnames
-repackageclasses ''
-allowaccessmodification

Hope it helps

yuku said...

I got this when I execute mvn:


Missing:
----------
1) sun:applet-jsobject:jar:1.4

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=sun -DartifactId=applet-jsobject -Dversion=1.4 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=sun -DartifactId=applet-jsobject -Dversion=1.4 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.microemu:microemu-javase-swing:jar:3.0.0-SNAPSHOT
2) sun:applet-jsobject:jar:1.4

----------
1 required artifact is missing.

for artifact:
org.microemu:microemu-javase-swing:jar:3.0.0-SNAPSHOT

from the specified remote repositories:
central (http://repo1.maven.org/maven2)


===============

I've copied plugin.jar and install it to ~/.m2/repository/sun/applet-jsobject/1.4
as applet-jsobject-1.4.jar

but, the error message still appears.

Anything missing?

Bartek Teodorczyk said...

Mark Gillespie,

The issue with converting F1 application turned out to be more difficult that I anticipated before. I've spent couple hours investigating the problem, but I didn't find any solution. I think, it would be the best if you create a bug report in our issues database: http://code.google.com/p/microemu/issues/list

Mark Gillespie said...

Thanks for taking a look.

I have raised a bug report on this:

http://code.google.com/p/microemu/issues/detail?id=40

Unfortunately, the application crash message did not tell me much, so the bug report is rather vague.

Bartek Teodorczyk said...

yuku,

I removed dependency to the applet-jsobject. You should be able to build the project now. Remember not to include revision parameter in svn, change is commited to the trunk.

yuku said...

Hi Bartek

It works amazingly! Thank for responding so quickly.

Ekke said...

Hi there.

I followed you tutorial and the build is successful. But when i try to run the .apk file in the android emulator it wont start..

During the ant build phase i get the lots of rows with the print:

[exec] warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.)

any idea of how to solve this?
Thanks in advance.

Kind Regards
/Erik Carlsson

Bartek Teodorczyk said...

Erik,

Did you get any suspicious error in logcat?

The warning that you mentioned can be ignored. It has no negative consequences for the converted code.

I'd like to encourage to use our groups for further discussions: http://groups.google.com/group/microemulator-support and http://groups.google.com/group/microemulator-developers

Richard said...

I am right in assumming you can use this process to convert. Any midp program to android.

Bartek Teodorczyk said...

Richard,

Yes you are right.

Richard said...

Your instruction needs to be made simpler, I have never used maven or ant. I have learnt maven now I have to learn ant. You need to dummy version

Richard said...

This is the logcat output that relates to an android 1.6, could you tell me what the problem is.
And also is there a way to get it to package it to a lower level. I can almost get my program to work on android level 7 2.1 but it doesnt work on a customItem I created.



V/MicroEmulator( 179): java.lang.VerifyError: intrface.Control
V/MicroEmulator( 179): at java.lang.Class.newInstanceImpl(Native Method)
V/MicroEmulator( 179): at java.lang.Class.newInstance(Class.java:1472)
V/MicroEmulator( 179): at org.microemu.app.Common.loadMidlet(Common.java:418)
V/MicroEmulator( 179): at org.microemu.app.Common.initMIDlet(Common.java:1054)
V/MicroEmulator( 179): at org.microemu.android.MicroEmulator.onCreate(MicroEmulator.java:175)
V/MicroEmulator( 179): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
V/MicroEmulator( 179): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
V/MicroEmulator( 179): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
V/MicroEmulator( 179): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
V/MicroEmulator( 179): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
V/MicroEmulator( 179): at android.os.Handler.dispatchMessage(Handler.java:99)
V/MicroEmulator( 179): at android.os.Looper.loop(Looper.java:123)
V/MicroEmulator( 179): at android.app.ActivityThread.main(ActivityThread.java:4203)
V/MicroEmulator( 179): at java.lang.reflect.Method.invokeNative(Native Method)
V/MicroEmulator( 179): at java.lang.reflect.Method.invoke(Method.java:521)
V/MicroEmulator( 179): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
V/MicroEmulator( 179): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
V/MicroEmulator( 179): at dalvik.system.NativeStart.main(Native Method)
V/MicroEmulator( 179): destroyMIDletContext
V/MicroEmulator( 179):
W/dalvikvm( 179): threadid=25: thread exiting with uncaught exception (group=0x4001aa28)
E/AndroidRuntime( 179): Uncaught handler: thread Thread-13 exiting due to uncaught exception
E/AndroidRuntime( 179): java.lang.NullPointerException
E/AndroidRuntime( 179): at org.microemu.MIDletBridge.getMIDletAccess(MIDletBridge.java:119)
E/AndroidRuntime( 179): at org.microemu.android.MicroEmulator$3.run(MicroEmulator.java:203)
E/AndroidRuntime( 179): at java.lang.Thread.run(Thread.java:1060)
I/Process ( 54): Sending signal. PID: 179 SIG: 3
I/dalvikvm( 179): threadid=7: reacting to signal 3
I/dalvikvm( 179): Wrote stack trace to '/data/anr/traces.txt'
I/ARMAssembler( 54): generated scanline__00000077:03515104_00000000_00000000 [ 27 ipp] (41 ins) at [0x28e090:0x28e134] in 949073 ns
I/ARMAssembler( 54): generated scanline__00000077:03515104_00001001_00000000 [ 64 ipp] (84 ins) at [0x28e138:0x28e288] in 2307905 ns
I/ARMAssembler( 54): generated scanline__00000077:03515104_00000001_00000000 [ 46 ipp] (65 ins) at [0x28e290:0x28e394] in 842286 ns
I/ActivityManager( 54): Displayed activity org.microemu.android.intrface.MainMenu/org.microemu.android.MicroEmulator: 2305 ms (total 2305 ms)
D/dalvikvm( 98): GC freed 1889 objects / 102984 bytes in 140ms

Bartek Teodorczyk said...

Richard,

I have moved the discussion to the support discussion group:
http://groups.google.com/group/microemulator-support/browse_thread/thread/c7669928119f7d99

Steve said...

I used the procedure documented above to convert a MIDP application, supplied on CD along with a security camera system, and it run successfully on my Nexus One.

I had to change some of the entries in build.xml because they assume android SDK 1.6 and I have v8.

I simply copied the resultant APK file to my N1 and ran it by finding it with Astro File Manager and choosing to open it with the application manager.

It took a few mins to figure out how the keyboard and user interface worked but after that I'm now able to remote view and remote control my security camera system from my N1.

Thank you for providing this solution.

Ar said...

can you help me :

Error after I execute ant command.

compile:
[javac] C:\EXTRACTED\microemulator-2.0.3\microemu-android\build.xml:103: war
ning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; se
t to false for repeatable builds
[javac] Compiling 21 source files to C:\EXTRACTED\microemulator-2.0.3\microe
mu-android\bin\classes
[javac] C:\EXTRACTED\microemulator-2.0.3\microemu-android\src\org\microemu\a
ndroid\device\ui\AndroidAlertUI.java:27: cannot find symbol
[javac] symbol : variable styleable
[javac] location: class android.R
[javac] TypedArray a = titleView.getContext().ob
tainStyledAttributes(android.R.styleable.Theme);
[javac]
^
[javac] C:\EXTRACTED\microemulator-2.0.3\microemu-android\src\org\microemu\a
ndroid\device\ui\AndroidAlertUI.java:28: cannot find symbol
[javac] symbol : variable styleable
[javac] location: class android.R
[javac] titleView.setTextAppearance(titleView.ge
tContext(), a.getResourceId(android.R.styleable.Theme_textAppearanceLarge, -1));

[javac]
^

It's found 14 error (I not post all stack trace) and this is end of stack trace :

[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 14 errors

BUILD FAILED
C:\EXTRACTED\microemulator-2.0.3\microemu-android\build.xml:103: Compile failed;
see the compiler error output for details.

Total time: 2 seconds
C:\EXTRACTED\microemulator-2.0.3\microemu-android>


Thank you...
Armi

Bartek Teodorczyk said...

Ar,

You have to checkout the MicroEmulator from repository instead of using MicroEmulator 2.0.3 version.

This is the command to checkout:
svn co http://microemu.googlecode.com/svn/trunk/microemulator microemulator -r 2211

perumal said...

Hi,

I followed your instructions, but after 'ant', I am getting the following error:

"...microemu-jsr-75.jar... doesn't exist"

Any idea how to resolve this issue?

Regards

Bartek Teodorczyk said...

perumal,

Let's move the discussion to the group: http://groups.google.com/group/microemulator-support

Please provide full error log.

perumal said...

Ok,

Have posted there already.

thewriteonafrica said...

Hi Bartek Teodorczyk,

I must really commend you on your work and assisstance. The manner in which you render assisstance to your blog writers and comments is just wonderful. It ssounds as if you've known them for ages. I'm really impressed.

I am very new to all this mobile apps development on any platform, but i am very much interested in developing, so i was wondering if you can help me decide on which platform to develop for (android or j2me). A suggestion from an expert like you that have used both environments will certainly go a long way in setting me up.

Thank you in advance.

*** my main target is the developing countries in Africa and ... China. Thanks.

j said...

hi there ;) great tut but ive got an issue at the last step of apk creation.. here is the error:

read-jad:
[echo] midlet.name = [${midlet.name}]

BUILD FAILED
D:\Programs\Java\SlikSvn\microemulator\microemu-android\build.xml:131: No midle
t name defined in jad.

i already created MIDlet-Name: bla.blah.bla but didnt change anything... pls help ;)

sam said...

Hi,

When i try to convert my application using micro-emulator i get the following error

package-res:
[exec] (skipping index file 'bin\assets\res\Thumbs.db')
[exec] invalid resource directory name: bin\res/applauncher.png

BUILD FAILED.

How ever when i check C:\Google_Andriod\microemulator\microemu-android\bin\res
the applauncher.png is present
am i missing out something? Kindly help me with this.

Thanking you,
Regards,
S.A.Norton Stanley

renzo said...

Hi there,

I built MicroEmulator from sources by creating an Eclipse project run with Maven. Everything works fine except this error on Eclipse:
"The type javax.microedition.io.ConnectionNotFoundException cannot be resolved. It is indirectly referenced from required .class files" on element MicroEmulatorActivity.java in org.microemu.android package.
It sounds like MicroEmulator can't see microemu-cdlc.
So I checked required projects on the build path and everything sounds good: MicroEmulator refers to microemu-midp which refers itself to microemu-cldc.
Any ideas?

Bartek Teodorczyk said...

renzo,

First of all I'd recommend to move the discussion to the http://groups.google.com/group/microemulator-support

Can you make a screenshot of your Eclipse project dependencies?

fire nyx said...

Hi,

Is there an idiots guide somewhere - I have no programming knowledge and all I would like to do is convert some .jar books to .apk files so I can read these books on my android phone.

Thanks,
Leigh

Bartek Teodorczyk said...

fire nyx,

At the moment there is no simple way to do that. Sorry.

Eternal Sunshine said...

hello sir,

-->I tried it BUILD successful.

But i got this warning before creation of apk file.
"THIS TOOL IS DEPRECATED. See --help for more information."

Can you help me why its giving that.

Thanks in advance.

Bartek Teodorczyk said...

Eternal Sunshine,

You can ignore that warning. It doesn't affect the build process.

specx2 said...

Hello Bartek Teodorczyk, excuse for bad English.
Thanks that be engaged, so necessary project.
Prompt, whether it is realised here API jsr 82.
I am ready, to pay money if there will be a possibility to use Bluetooth in J2ME.

Bartek Teodorczyk said...

specx2,

JSR-82 for Android is available from MicroEmu company. Please send your email to the info at microemu.com and we will contact you.

specx2 said...

Forgive, has not absolutely understood where it is necessary to send the letter.
Please communicate with me through specx2@rambler.ru
In advance I thank.

Jelmer said...

Hi,

I am trying to build an apk for the Android Market. I am following the steps from:
http://developer.android.com/guide/publishing/app-signing.html

So, I have generated a keystore/key pair and put the appropriate property settings in the build.xml file. Now, when I try to run

ant release

it tells me:
BUILD FAILED
Target "release" does not exist in the project "microemu-android".

Building with just the "ant" command works just fine, and the resulting app works on my android device. I just can't publish it in the Market, as these apps need to be signed and built for release.

Does anyone know how to solve this? How should I adapt the build.xml file to support a "release target", whatever that may be...?

Thanks a lot!
Jelmer

Bartek Teodorczyk said...

Jelmer,

You should use the ant packege-apk target for building release version as well. If you have any more questions send it over: http://groups.google.com/group/microemulator-support

actinium said...

Hi Bartek,

Thanks for your work.

I'm getting a small issue while converting a jar to apk. I created the .jad file from manifest.mf as I didn't have any.
the apk building stage (through ant) fails with following message:

compile:
[javac] Warning: org/microemu/android/com/infosys/dynacred/ui/DynaCredMIDLet/R.java modified in the future.
[javac] Compiling 27 source files to /jar2apk/uEmu/microemulator/microemu-android/bin/classes
[javac] Note: /jar2apk/uEmu/microemulator/microemu-android/src/org/microemu/android/MicroEmulator.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

dex:
[exec] Error occurred during initialization of VM
[exec] Could not reserve enough space for object heap
[exec] Could not create the Java virtual machine.

BUILD FAILED
/jar2apk/uEmu/microemulator/microemu-android/build.xml:211: exec returned: 1

Can you please let me know what I'm doing wrong?

Thanks
actinium

Bartek Teodorczyk said...

actinium,

Set in the dx.bat to javaOpts=-Xmx1024M

actinium said...

@Bartek: Thanks for the nifty response. I confirmed this setting in dx script; it is already set to work with 1024MBs.
I'm using Android 2.2 APIs on an openSUSE 11.4, with the same revision number as mentioned in the blog-post (2211). Could deviation from Android 1.6 be a cause of the problem?

Bartek Teodorczyk said...

actinium,

Yes, that's possible.

To continue technical discussions, I suggest using the: http://groups.google.com/group/microemulator-support

Rochmat said...

C:\Program Files\SlikSvn\bin\microemulator\microemu-android>D:\installer\java\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\bin\ant
Buildfile: build.xml

clean:
[delete] Deleting directory C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin

check:

dirs:
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\assets
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\classes
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\producer
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\res
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\libs

compile-producer:
[javac] Compiling 6 source files to C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\producer

read-jad:
[echo] midlet.name = [MC Fin@net]
[echo] midlet.icon.totrim = [/fin.png]
[echo] midlet.icon = [/fin.png]
[echo] midlet.class.totrim = [mobile.wallet.FinnetMC]

prepare-jars:

prepare-assets:
[unzip] Expanding: D:\busdev\project\MC by GPRS\product\indo\FinnetMC.jar into C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\asse
[copy] Copying 1 file to C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\assets

prepare-res:
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\res\values
[mkdir] Created dir: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\res\drawable
[unjar] Expanding: D:\busdev\project\MC by GPRS\product\indo\FinnetMC.jar into C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin
[copy] Copying 1 file to C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\res\drawable

package-res:

compile:
[javac] Compiling 33 source files to C:\Program Files\SlikSvn\bin\microemulator\microemu-android\bin\classes
[javac] Note: C:\Program Files\SlikSvn\bin\microemulator\microemu-android\src\org\microemu\android\MicroEmulator.java uses unchecked or unsafe oper
ons.
[javac] Note: Recompile with -Xlint:unchecked for details.

dex:
[exec] =C:\Program was unexpected at this time.

BUILD FAILED
C:\Program Files\SlikSvn\bin\microemulator\microemu-android\build.xml:248: exec returned: 255

Total time: 5 seconds

please help me? whay that occour

Bartek Teodorczyk said...

Rochmat,

Install the Android SDK in a path without spaces in name. In your case the problem is space in "Program Files".

Rochmat said...

dear Bartek,

thank u for reply, it work.

but when i installed in my android, i got warning "The application MC Fin@net(process org.microemu.android.mobile.wallet.FinnetMC) has stopped unexpectedly. please try again."
and then application not work.

is there any wrong in my android?

Bartek Teodorczyk said...

Rochmat,

Did you get any suspicious error in logcat? Instructions for using logcat are here: http://developer.android.com/guide/developing/tools/logcat.html

I'd like to encourage to use our groups forum for further discussions: http://groups.google.com/group/microemulator-support

waheed said...

I have tried the whole project but the ant fails to build with following error
BUILD FAILED
/root/microemulator/microemu-android/build.xml:134: No midlet name defined in jad.

My jad file is

MIDlet-1: OPDA,,OPDA

MIDlet-Jar-Size: 50384

MIDlet-Jar-URL: MPD.jar

MIDlet-Name: MPD
MIDlet-Permissions: javax.microedition.amms.control.camera.enableShutterFeedback

MIDlet-Vendor: Vendor

MIDlet-Version: 1.0

MicroEdition-Configuration: CLDC-1.1

MicroEdition-Profile: MIDP-2.0


What could possibly be wrong?

Bartek Teodorczyk said...

waheed,

Sounds like build script cannot find the jad file.

For the technical discussion, let's move to the groups: http://groups.google.com/group/microemulator-support

sebastian_bugiu said...

Yeah I have the same problem as waheed.

MIDlet-Jar-URL: SpaceRocket.jar
MIDlet-Name: SpaceRocket
MIDlet-Vendor: Vendor
MIDlet-Version: 1.0
MIDlet-1: SpaceRocket,,spaceRocket_pack.SpaceRocket
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0

No matter what I do it still says No midlet name defined in jad.

mf said...

Hi,
I'm I've never used any of these programs before and want to try and learn how to convert java to android. Is there any video tutorials / other guides that can help me? Cheers

ahmad said...

hi;
there is problem for me to build project with maven.
I got these errors:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building microemulator 3.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.microemu:microemu-javase-swing:jar:3.0.0-SNAPSHOT is m
issing, no dependency information available
[WARNING] The POM for org.microemu:microemu-injected:jar:inject:3.0.0-SNAPSHOT i
s missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.380s
[INFO] Finished at: Sun Sep 11 16:11:25 IRDT 2011
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project microemulator: Could not resolve depen
dencies for project org.microemu:microemulator:pom:3.0.0-SNAPSHOT: The following
artifacts could not be resolved: org.microemu:microemu-javase-swing:jar:3.0.0-S
NAPSHOT, org.microemu:microemu-injected:jar:inject:3.0.0-SNAPSHOT: Failure to fi
nd org.microemu:microemu-javase-swing:jar:3.0.0-SNAPSHOT in ../repository.pyx4j.
com/maven2-snapshot was cached in the local repository, resolution will not be r
eattempted until the update interval of pyx4j-public-snapshot has elapsed or upd
ates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
D:\Android-programming\Android\micro\microemulator-2.0.4\microemulator>

please help me! this is very important for me!

ahmad said...

hi, thanks for reply!!!!
I solved that problem myself.
but I faced another stupid problem;
this is the error:

compile-producer:

BUILD FAILED
D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microemu-android\b
uild.xml:81: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre1.6.0_20"

Total time: 0 seconds

it's going to make me hopeless.
please help me.

ahmad said...

hi, thanks for reply!!!!
I solved that problem myself.
but I faced another stupid problem;
this is the error:

compile-producer:

BUILD FAILED
D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microemu-android\b
uild.xml:81: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre1.6.0_20"

Total time: 0 seconds

it's going to make me hopeless.
please help me.

Bartek Teodorczyk said...

ahmad,

You need to download and install JDK instead of JRE from this location: http://www.oracle.com/technetwork/java/javase/downloads/index.html

ahmad said...

thanks, it solved.
but I got some another error:
I don't understand what's going on happen !
these are errors

[javac] ^
[javac] D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microe
mu-android\src\org\objectweb\asm\javax\xml\transform\dom\DOMResult.java:238: can
not find symbol
[javac] symbol : variable DOCUMENT_POSITION_CONTAINED_BY
[javac] location: interface org.w3c.dom.Node
[javac] if ((node.compareDocumentPosition(nextSibling)&Node.DOCU
MENT_POSITION_CONTAINED_BY)==false) {
[javac] ^
[javac] D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microe
mu-android\src\org\objectweb\asm\javax\xml\transform\dom\DOMResult.java:296: can
not find symbol
[javac] symbol : method compareDocumentPosition(org.w3c.dom.Node)
[javac] location: interface org.w3c.dom.Node
[javac] if ((node.compareDocumentPosition(nextSibling)&Node.DOCU
MENT_POSITION_CONTAINED_BY)==false) {
[javac] ^
[javac] D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microe
mu-android\src\org\objectweb\asm\javax\xml\transform\dom\DOMResult.java:296: can
not find symbol
[javac] symbol : variable DOCUMENT_POSITION_CONTAINED_BY
[javac] location: interface org.w3c.dom.Node
[javac] if ((node.compareDocumentPosition(nextSibling)&Node.DOCU
MENT_POSITION_CONTAINED_BY)==false) {
[javac] ^
[javac] Note: D:\Android-programming\Android\micro\mine\microemulator-2.0.4\
microemu-android\src\org\objectweb\asm\javax\xml\bind\helpers\AbstractUnmarshall
erImpl.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 56 errors

BUILD FAILED
D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microemu-android\b
uild.xml:106: Compile failed; see the compiler error output for details.
Total time: 4 seconds

ahmad said...

hi bartek.
there is a problem when I want to get apk:

[javac] D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microe
mu-android\src\org\microemu\android\device\ui\AndroidTextBoxUI.java:63: cannot f
ind symbol
[javac] symbol : variable styleable
[javac] location: class android.R
[javac] TypedArray a = titleView.getContext().ob
tainStyledAttributes(android.R.styleable.Theme);
[javac]

I use microemu2.0.4;
what should I do?

ahmad said...

hi;
I got these errors:
any body help me?

[javac] D:\Android-programming\Android\micro\mine\microemulator-2.0.4\microe
mu-android\src\org\microemu\android\device\ui\AndroidAlertUI.java:27: cannot fin
d symbol
[javac] symbol : variable styleable
[javac] location: class android.R

Bartek Teodorczyk said...

ahmad,

Can we move the technical discussion to the groups forum at http://groups.google.com/group/microemulator-support ?

You should use the repository version of MicroEmulator not the 2.0.4 release. Use the following command to checkout the project:
svn co http://microemu.googlecode.com/svn/trunk/microemulator microemulator -r 2211

Gabriel said...

hello guys,

i have this problem when i try to build micro emulator using mvn :

INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project microemulator: Could not resolve depen
dencies for project org.microemu:microemulator:pom:3.0.0-SNAPSHOT: The following
artifacts could not be resolved: org.microemu:microemu-javase-swing:jar:3.0.0-S
NAPSHOT, org.microemu:microemu-injected:jar:inject:3.0.0-SNAPSHOT: Could not fin
d artifact org.microemu:microemu-javase-swing:jar:3.0.0-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
C:\Users\azg\Desktop\emulater\microemulator>

Ahmed u had the same problem could you post how you solve it .

Best Regards.

Herr Tütschek said...

Hi,

thanks for this great possibility! I've tried it and it works OK (you only have to use ASM 3.2 and Maven 2 – not the newer versions – and modify the Android SDK path in the build file).

But I don't have keyboard on my phone and would like to convert an app that requires one – is there a way to emulate a physical phone keyboard?

All the best,
Tuetschek

Oliver Pfeiffer said...

Hello together! I've run across this recipe trying to convert a little java me game I wrote on my own. I followed the first 5 conversion steps letter by letter, yet I obviously ran into the same problem that occurs in this older post. In my case the last few lines of the ant output read:

prepare-res:
[mkdir] Created dir: S:\Internet\microemulator\microemu-android\bin\res\values
[mkdir] Created dir: S:\Internet\microemulator\microemu-android\bin\res\drawable
[unjar] Expanding: S:\Projekt\java\Eigene\Mobiles\Korean\mobiles\korean.jar into S:\Internet\microemulator\microemu-android\bin
[copy] Copying 1 file to S:\Internet\microemulator\microemu-android\bin\res\drawable

package-res:
[exec] invalid resource directory name: bin\res/Images

BUILD FAILED
S:\Internet\microemulator\microemu-android\build.xml:274: exec returned: 1

Comparing my output with that in the aforementioned post I would guess there is some probem with mixing forward and backward slashes. But perhaps the reason is some other problem which I'm unable to judge whether it has already been fixed in a more recent revision or not. I think I would be able to fix this issue myself if someone could point me into the correct direction. Any help greatly appreciated. Best regards, Oliver Pfeiffer

RadioGiurumele said...

Hello!

I would like to convert SonicJump.jar (Java game for Nokia N73) to an .apk, in order to run on my Android (2.3.3 Gingerbread).

This is the game:
http://www.mediafire.com/?rv136n6mv3fvf81

Is this possible using MicroEmu ? Sorry for my question, but I'm not a coder.

In the hope of an answer, please allow me to congratulate you for the very nice work at MicroEmu !

Funkmuseum

Bartek Teodorczyk said...

RadioGiurumele,

Do you know who is the producer of this game? Maybe it would be better to contact them and ask for permission.

zeAtBlogg said...

Amazing job, thank you. -- Failed to build microemulator 2211, 2450 and 2525 with the latest JDK-7u2 and Maven 2.2.1 or 3.0.4, it says it's unable to load rt.jar, it has to do with some version of something. I'm now downloading JDK-6u25 to see if that's gonna solve it since I assume that version could be closer to the JDK version you originally used when making this tutorial. QUESTION: could you please be specific and tell us exactly what version of JDK, Maven, Android, ASM and ANT were you using, or what are the latest versions of these tools that you successfully used for this?

Bartek Teodorczyk said...

zeAtBlogg,

I didn't test the conversion with the JDK-7 and I'm suspecting it may be a cause of your problem. Try with JDK-6 and let me know if the problem still exists.

zeAtBlogg said...

Yep, JDK-6u25 did the job, with Maven 2.2.1, so now I'll be having fun trying to convert some stuff. Is there any place on the Internet where such converted apps can be found, so maybe I can upload my conversions there too? -- Now, as I managed to figure out Google is banning anything from Android Market that has to do with J2ME emulation, do you know what is their reason? I also see at some point there were some apps on the Android Market that are not there anymore, which do exist as J2ME apps, so were most likely conversions, and again, what is the problem Google has with it, considering the apps I'm talking about were free to start with?

zeAtBlogg said...

Converted several games and they seem to work great. Even GBA emulator running some Pokemone game works fine, although it crashes when sound is enabled.

Tried 7-8 different Metal Gears, MGS classic and MG Acids, none of them did work. Tried 5-6 different Zeldas, all force close at start. Actually the games that do work do not have sound, so my question now is whether the sound is supposed to be working at all?

I should also mention probably that I used Android 2.3 which they call "Android-8", so I had to make some additional changes to "build.xml" as the directory structure is a bit different, and I can post here about it if you like. In any case, do you think whether there is a chance some of those non-working apps might actually end up working if I use older Android SDK as you did?

All in all I find this is a great project, especially since many have laughed about it before and said converting J2ME jar to Android apk would be impossible. Well, I'm glad the impossibility of it didn't stop you, hehee, keep up the good work!


Crazy Internet Crusader,
www.geocities.com/ze_aks/myos.html

Bartek Teodorczyk said...

zeAtBlogg,

Can we move the discussion to the other place? it would be easier to talk on our support group:
http://groups.google.com/group/microemulator-support

I'll put answers there

PurplePants said...

getting compiler errors when doing the last ant build:
compile-producer:
[javac] D:\marius\mobetAndr\microemu-android\build.xml:134: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 6 source files to D:\marius\mobetAndr\microemu-android\bin\producer
[javac] D:\marius\mobetAndr\microemu-android\src\org\microemu\android\asm\FirstPassVisitor.java:40: interface expected here
[javac] public class FirstPassVisitor implements ClassVisitor {
[javac] ^
[javac] D:\marius\mobetAndr\microemu-android\src\org\microemu\android\asm\AndroidClassVisitor.java:229: incompatible types
[javac] found : org.microemu.android.asm.AndroidClassVisitor.AndroidMethodVisitor
[javac] required: org.objectweb.asm.MethodVisitor
[javac] return new AndroidMethodVisitor(super.visitMethod(access, name, desc, signature, exceptions));
[javac] ^
[javac] D:\marius\mobetAndr\microemu-android\src\org\microemu\android\asm\AndroidProducer.java:59: cannot find symbol
[javac] symbol : method accept(org.microemu.android.asm.FirstPassVisitor,int)
[javac] location: class org.objectweb.asm.ClassReader
[javac] cr.accept(cv, 0);
[javac] ^
[javac] D:\marius\mobetAndr\microemu-android\src\org\microemu\android\asm\AndroidProducer.java:77: incompatible types
[javac] found : org.microemu.android.asm.AndroidClassVisitor
[javac] required: org.objectweb.asm.ClassVisitor
[javac] ClassVisitor cv = new AndroidClassVisitor(cw, isMidlet,
classesHierarchy, fieldTranslations);
[javac] ^
[javac] 4 errors

BUILD FAILED
D:\marius\mobetAndr\microemu-android\build.xml:134: Compile failed; see the compiler error output for details.

Total time: 0 seconds

Bartek Teodorczyk said...

PurplePants,

What version from SVN do you use, the latest trunk or revision 2211?

Super Mario said...

Please help me!
I dont understand what daes it mean

cd microemulator
mvn

cd microemu-android
ant

How to use Ant and Maven? I hever use it before. One more question :


May I use absolute pathes ? Or sdk mast be in path relative to this xml file?

p.s Excusme for my English? I am not native speaker

Super Mario said...

Please help me!
I don't understund this:

cd microemulator
mvn

cd microemu-android
ant

I suppose to change dir and... what is then?
I never use ant and maven before.

One more question:





What does mean $HOME ?

Fabio said...

Hi guys! Could anyone please convert opera mini 6.5 or opera mini next java versions to an APK? I know since the normal apk won't work on android-x86 and I would try if maybe the ported javame does :)

Denis Kobernik said...

Hello Bartek,
I run microemulator on Ubuntu and I don't have any errors but I can't run apk file on android device. I had it working but after I reinstalled jdk it don't want to build apk file correctly. I tried different versions, nothing helped. I saw that if "dex" is empty then apk file will be incorret. Maybe I have incorrect build.xml, I don't know. Help me please.
compile:
[javac] /home/denis/Programs/microemulator/microemu-android/build.xml:226: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 35 source files to /home/denis/Programs/microemulator/microemu-android/bin/classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: /home/denis/Programs/microemulator/microemu-android/src/org/microemu/android/MicroEmulator.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

dex:

package-apk:
[exec]
[exec] THIS TOOL IS DEPRECATED. See --help for more information.
[exec]

BUILD SUCCESSFUL

chidiseg said...

hi, if you guys say its possible to convert java apps to .apk, please has any one been able to convert bbm successfully? let some one do it n lrt us all benefit from it. or if any one of u is having it please share with us.


chidiseg@gmail.com

viet ep said...

Can you make video how to

yuanz lixz said...

help me first time use it, i already download but i don't know how to use it

Cyberster said...

I'm trying to convert a jar (livechat.jar/livechat.jad) to apk... but getting following errors...
I also tried with 5UD0KU, but same...

I'm using Subversion-1.6.0, jdk1.6.0_24, apache-ant-1.9.2, apache-maven-2.2.1
Please help me...

C:\Users\Cyberster\microemulator\microemu-android>%ant%ant
Buildfile: C:\Users\Cyberster\microemulator\microemu-android\build.xml

clean:
[delete] Deleting directory C:\Users\Cyberster\microemulator\microemu-android\bin

check:

dirs:
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\assets
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\classes
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\producer
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\res
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\libs

compile-producer:
[javac] C:\Users\Cyberster\microemulator\microemu-android\build.xml:94: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 6 source files to C:\Users\Cyberster\microemulator\microemu-android\bin\producer

read-jad:
[echo] midlet.name = [LiveChat]
[echo] midlet.icon.totrim = [ /icon.png]
[echo] midlet.icon = [/icon.png]
[echo] midlet.class.totrim = [ avacs.c]

prepare-jars:

prepare-assets:
[unzip] Expanding: C:\Users\Cyberster\microemulator\microemu-android\livechat.jar into C:\Users\Cyberster\microemulator\microemu-android\bin\assets
[copy] Copying 1 file to C:\Users\Cyberster\microemulator\microemu-android\bin\assets

prepare-res:
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\res\values
[mkdir] Created dir: C:\Users\Cyberster\microemulator\microemu-android\bin\res\drawable
[unjar] Expanding: C:\Users\Cyberster\microemulator\microemu-android\livechat.jar into C:\Users\
Cyberster\microemulator\microemu-android\bin
[copy] Copying 1 file to C:\Users\Cyberster\microemulator\microemu-android\bin\res\drawable

package-res:

compile:
[javac] C:\Users\Cyberster\microemulator\microemu-android\build.xml:187: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 31 source files to C:\Users\Cyberster\microemulator\microemu-android\bin\classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: C:\Users\Cyberster\microemulator\microemu-android\src\org\microemu\android\MicroEmulator.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

dex:
[exec] Unable to access jarfile ..\framework\dx.jar

BUILD FAILED
C:\Users\Cyberster\microemulator\microemu-android\build.xml:209: exec returned: 1

Total time: 10 seconds

Cyberster said...

Hello Bartek,
By the way, right after just post my previous comment... I've gone through error logs and found the problem was caused by missing dx.jar path.
Then I've converted 5ud0ku and microemu-demo... They works fine...

But most of all other converted APKs are not working.
Getting "Unfortunately, *app_name* has stopped." error in android.

I dig into jar files and found that JARs with MANIFEST.MF -> MIDlet-1: ... ending with MIDlet only are working.

Example:
MIDlet-1: Devil May Cry, /icon.png, DMC2DMIDlet => working
MIDlet-1: BOLT,/icon.png,THJava => not working

Can you please explain this?
Thanks a lot for microemu :)