Search code examples
androidlogcat

Game force closing at various times. Need help Interpreting logCat warnings and errors


My game starts with a splash screen and plays music until someone touches the screen or the given amount of time expires. It then goes to the menu activity which has two buttons, one to start the game and another to open an about activity that pops up a transparent window telling the user about the game.

My current problem is that sometimes when I start the game I get a force close right away, or when I touch the screen to skip the splash, when I press start to play the game, and even in this errors specific case I pressed the about button. The weird thing for me is that sometimes everything works.

I am getting a lot of these errors even if it works, I just need some help interpreting them so I can fix 'em. I am not sure at which point I started getting these force closes because it was consistently working before. I've always had errors though and I don't want something unstable.

If you need additional info to help, you know where I am. :D

Thanks and I can't wait to get this application back on track so I can work on features!!

Errors below are the result of running my game and at the main menu pressing about and getting a force close.

 09-11 20:54:53.984: WARN/AudioFlinger(34): write blocked for 82 msecs, 23 delayed writes, thread 0xb3f0
    09-11 20:54:55.314: WARN/TimedEventQueue(34): Event 15 was not found in the queue, already cancelled?
    09-11 20:54:55.314: ERROR/MediaPlayer(302): stop called in state 1
    09-11 20:54:55.314: ERROR/MediaPlayer(302): error (-38, 0)
    09-11 20:54:55.354: ERROR/global(302): Deprecated Thread methods are not supported.
    09-11 20:54:55.354: ERROR/global(302): java.lang.UnsupportedOperationException
    09-11 20:54:55.354: ERROR/global(302):     at java.lang.VMThread.stop(VMThread.java:85)
    09-11 20:54:55.354: ERROR/global(302):     at java.lang.Thread.stop(Thread.java:1379)
    09-11 20:54:55.354: ERROR/global(302):     at java.lang.Thread.stop(Thread.java:1344)
    09-11 20:54:55.354: ERROR/global(302):     at com.ss.game.Splash$1.run(Splash.java:61)
    09-11 20:55:22.915: WARN/TimedEventQueue(34): Event 2 was not found in the queue, already cancelled?
    09-11 20:55:22.925: WARN/dalvikvm(302): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302): FATAL EXCEPTION: main
    09-11 20:55:22.945: ERROR/AndroidRuntime(302): java.lang.RuntimeException: Unable to pause activity {com.ss.game/com.ss.game.MyMenu}: java.lang.NullPointerException
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3348)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3305)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3288)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread.access$2500(ActivityThread.java:125)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.os.Looper.loop(Looper.java:123)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at java.lang.reflect.Method.invoke(Method.java:521)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at dalvik.system.NativeStart.main(Native Method)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302): Caused by: java.lang.NullPointerException
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at com.ss.lastzombie.MyMenu.onPause(MyMenu.java:78)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.Activity.performPause(Activity.java:3842)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1190)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3335)
    09-11 20:55:22.945: ERROR/AndroidRuntime(302):     ... 12 more
    09-11 20:55:23.477: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{43fea4f8 com.ss.game/.MyMenu}
    09-11 20:55:32.984: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
    09-11 20:55:33.454: WARN/InputManagerService(59): Got RemoteException sending setActive(false) notification to pid 302 uid 10032

Solution

  • Start with this:

    ERROR/MediaPlayer(302): stop called in state 1
    

    MediaPlayer wants it's methods to be called in particular order. See the state diagram: http://developer.android.com/reference/android/media/MediaPlayer.html

    It seems you are calling it in idle (1) state: http://androidxref.com/2.2.3/xref/frameworks/base/include/media/mediaplayer.h#111