Well I have managed to successfully run BasicGame example as well as JME tests.
It bothers me that I cannot prepare my project to run. I configured it in exactly the same way as the BasicGame. I even have the package name the same, although I have a little more subpackages and classes. Any clues on what is wrong?
Error trace:
E/com.jme3.app.AndroidHarness( 2106): SEVERE Class mygame.Main init failed
E/com.jme3.app.AndroidHarness( 2106): java.lang.ClassNotFoundException: mygame.Main
E/com.jme3.app.AndroidHarness( 2106): at java.lang.Class.classForName(Native Method)
E/com.jme3.app.AndroidHarness( 2106): at java.lang.Class.forName(Class.java:217)
E/com.jme3.app.AndroidHarness( 2106): at java.lang.Class.forName(Class.java:172)
E/com.jme3.app.AndroidHarness( 2106): at com.jme3.app.AndroidHarness.onCreate(AndroidHarness.java:223)
E/com.jme3.app.AndroidHarness( 2106): at android.app.Activity.performCreate(Activity.java:5104)
E/com.jme3.app.AndroidHarness( 2106): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/com.jme3.app.AndroidHarness( 2106): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/com.jme3.app.AndroidHarness( 2106): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/com.jme3.app.AndroidHarness( 2106): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/com.jme3.app.AndroidHarness( 2106): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/com.jme3.app.AndroidHarness( 2106): at android.os.Handler.dispatchMessage(Handler.java:99)
E/com.jme3.app.AndroidHarness( 2106): at android.os.Looper.loop(Looper.java:137)
E/com.jme3.app.AndroidHarness( 2106): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/com.jme3.app.AndroidHarness( 2106): at java.lang.reflect.Method.invokeNative(Native Method)
E/com.jme3.app.AndroidHarness( 2106): at java.lang.reflect.Method.invoke(Method.java:511)
E/com.jme3.app.AndroidHarness( 2106): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/com.jme3.app.AndroidHarness( 2106): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/com.jme3.app.AndroidHarness( 2106): at dalvik.system.NativeStart.main(Native Method)
E/com.jme3.app.AndroidHarness( 2106): Caused by: java.lang.NoClassDefFoundError: mygame/Main
E/com.jme3.app.AndroidHarness( 2106): ⌠18 more
E/com.jme3.app.AndroidHarness( 2106): Caused by: java.lang.ClassNotFoundException: Didnât find class âmygame.Mainâ on path: /data/app/com.mygame-1.apk
E/com.jme3.app.AndroidHarness( 2106): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
E/com.jme3.app.AndroidHarness( 2106): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/com.jme3.app.AndroidHarness( 2106): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/com.jme3.app.AndroidHarness( 2106): ⌠18 more
E/com.jme3.app.AndroidHarness( 2106):
D/dalvikvm( 2106): GC_CONCURRENT freed 93K, 2% free 9033K/9156K, paused 5ms+4ms, total 36ms
D/dalvikvm( 2106): WAIT_FOR_CONCURRENT_GC blocked 28ms
W/dalvikvm( 2106): threadid=1: thread exiting with uncaught exception (group=0x40bb1930)
E/AndroidRuntime( 2106): FATAL EXCEPTION: main
E/AndroidRuntime( 2106): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mygame/com.mygame.MainActivity}: java.lang.NullPointerException
E/AndroidRuntime( 2106): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime( 2106): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime( 2106): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime( 2106): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime( 2106): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2106): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2106): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 2106): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2106): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2106): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 2106): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 2106): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2106): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 2106): at com.jme3.app.AndroidHarness.onCreate(AndroidHarness.java:235)
E/AndroidRuntime( 2106): at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime( 2106): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime( 2106): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidRuntime( 2106): ⌠11 more
W/ActivityManager( 499): Force finishing activity com.mygame/.MainActivity
@InShadow Can you post the zip file for the project to see if I can run it on my nexus 7. Give me a drop box link or something like that with a exported .zip file.
I can post apk file, because I donât know which zip you are referring to. But I presume it wonât work for you either. The error seems pretty clear to me, although I donât know why I get it. I will try to check configuration again or just copy paste the code to the BasicGame which works.
Check the build file (mobile-impl.xml), I think I had this issue onceâŚunfortunately I donât really remember how I fixed itâŚ
At worst, if you can make the basic game to run just copy your source code to a working project.
I did just that and it works lol!
I suspect the problem was in project configuration. My project was created with older version of SDK, while BasicGame I created just after updating to the latest SDK.
Hopefully it helps also someone else.
I think it is a problem with the build script, I have the same problem. Its not copying the source from the main project over to the mobile folder so when it builds its missing all of that. All the assets are copied though.
I had the problem with the missing class definition for a custom library.
The .class files were not dexed and did not enter the final apk.
Even manual dexing would not work with an exception: bad file magic (cafebabe)
The solution is to compile everything with JDK 5 or 6, but never with 7!
I hope everyone who has the same error finds this solution helpful.
by the way i just solve the issue above by doing the following :
in the âimportant filesâ of the project, locate the file âAndroid Main Activityâ and modify the variable âappClassâ set it to the complete name of your main class (example com.mycompany.com.MyMainClass)
Note : this java file does not need to compile in the project.