Unable to get my game to run on Android.

Monkey Targets Forums/Android/Unable to get my game to run on Android.

DeadFall(Posted 2013) [#1]
Hey I'm trying to test my game on my Android device. It will compile correctly and install on my device but when I try to open it, it just crashes.

Any idea why that might happen? I'm not sure if it's some code I'm using or what. Also is there a way I can make it so it'll print out an error? So I know what is happening to make it crash.


Volker(Posted 2013) [#2]
You can use ddms.bat in the android-sdk/tools folder.
Which Monkey version are you using?


Wagenheimer(Posted 2013) [#3]
I got the same problem with Monkey 67c.

02-15 22:37:42.079: E/ActivityThread(13281): Failed to inflate
02-15 22:37:42.079: E/ActivityThread(13281): android.view.InflateException: Binary XML file line #12: Error inflating class com.monkey.MonkeyGame$GameView
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-15 22:37:42.079: E/ActivityThread(13281): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:213)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.Activity.setContentView(Activity.java:1657)
02-15 22:37:42.079: E/ActivityThread(13281): at com.wagenheimer.rabbitjumpandroid.MonkeyGame.onCreate(MonkeyGame.java:1377)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
02-15 22:37:42.079: E/ActivityThread(13281): at android.os.Handler.dispatchMessage(Handler.java:99)
02-15 22:37:42.079: E/ActivityThread(13281): at android.os.Looper.loop(Looper.java:130)
02-15 22:37:42.079: E/ActivityThread(13281): at android.app.ActivityThread.main(ActivityThread.java:3835)
02-15 22:37:42.079: E/ActivityThread(13281): at java.lang.reflect.Method.invokeNative(Native Method)
02-15 22:37:42.079: E/ActivityThread(13281): at java.lang.reflect.Method.invoke(Method.java:507)
02-15 22:37:42.079: E/ActivityThread(13281): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
02-15 22:37:42.079: E/ActivityThread(13281): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
02-15 22:37:42.079: E/ActivityThread(13281): at dalvik.system.NativeStart.main(Native Method)
02-15 22:37:42.079: E/ActivityThread(13281): Caused by: java.lang.ClassNotFoundException: com.monkey.MonkeyGame$GameView in loader dalvik.system.PathClassLoader[/data/app/com.wagenheimer.rabbitjumpandroid-2.apk]
02-15 22:37:42.079: E/ActivityThread(13281): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
02-15 22:37:42.079: E/ActivityThread(13281): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
02-15 22:37:42.079: E/ActivityThread(13281): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
02-15 22:37:42.079: E/ActivityThread(13281): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
02-15 22:37:42.079: E/ActivityThread(13281): ... 20 more
02-15 22:37:42.699: D/dalvikvm(13281): threadid=1: still suspended after undo (sc=1 dc=1)


Wagenheimer(Posted 2013) [#4]
Any hint of what should i try? =(


therevills(Posted 2013) [#5]
Delete your build folder?


pantson(Posted 2013) [#6]
download v67e and test
There is a fix for device dimensions initializing to 0 for Android in v67c.
This was making my game crash, as I was doing some scaling stuff (and everything was dividing by 0)


Wagenheimer(Posted 2013) [#7]
Now it works on Simulator but does not seems to works on Real Device.

It keeps me showing :

02-18 20:47:14.215: E/AudioCache(1361): Heap size overflow! req size: 1056768, max size: 1048576
02-18 20:47:14.255: E/AudioCache(1361): Heap size overflow! req size: 1056768, max size: 1048576

Maybe this is causing the problem?


Wagenheimer(Posted 2013) [#8]
E/AudioCache( 1361): Heap size overflow! req size: 1056768, max size: 1048576
E/AndroidRuntime( 9714): FATAL EXCEPTION: main
E/AndroidRuntime( 9714): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.monkey/com.monkey.MonkeyGame}: java.lang.ClassNotFoundException: com.monkey.MonkeyGame in loader dalvik.system.PathClassLoader[/data/app/com.monkey-2.apk]
E/AndroidRuntime( 9714): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
E/AndroidRuntime( 9714): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime( 9714): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime( 9714): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime( 9714): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 9714): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 9714): at android.app.ActivityThread.main(ActivityThread.java:3835)
E/AndroidRuntime( 9714): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 9714): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 9714): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
E/AndroidRuntime( 9714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
E/AndroidRuntime( 9714): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 9714): Caused by: java.lang.ClassNotFoundException: com.monkey.MonkeyGame in loader dalvik.system.PathClassLoader[/data/app/com.monkey-2.apk]
E/AndroidRuntime( 9714): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
E/AndroidRuntime( 9714): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
E/AndroidRuntime( 9714): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime( 9714): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 9714): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
E/AndroidRuntime( 9714): ... 11 more


Wagenheimer(Posted 2013) [#9]
It is really a sound problem... Disabled all my sounds/music and now the game is working!

Any idea of how to fix it?


DeadFall(Posted 2013) [#10]
Hey thanks for the responses,

I was able to fix my problem by removing some images I was loading at start. They were all larger than 1024x1024 which is why the game was crashing. (Was developing my game for ios Retina display first)


slenkar(Posted 2013) [#11]
E/AudioCache( 1361): Heap size overflow! req size: 1056768, max size: 1048576


how big are your music/audio files?


Earok(Posted 2013) [#12]
I had this problem myself. It appears to be a general Android issue, apparently it doesn't like sound files that are bigger than 1mb.


MikeHart(Posted 2013) [#13]
In Monkeys documentation, it is stated that Android sound files should not be bigger than 1 MB.


Earok(Posted 2013) [#14]
Ah, I missed that somehow! I'll try using the Music commands, cheers :)