Game crashes in "super.onCreate(savedInstanceState);" after woken up

Hello,

I’m having a hard time trying to figure this out…
When I launch the game after having installed it, it runs fine; then if I tap the home button of the device (it happens on a Nexus 7), and then launch the game again by clicking on its icon, the game crashes and relaunch itself automatically. It does this each time I reduce it with the home button, until I restart the device. After a restart, the crashes do not happen anymore (although it happens 100% of the time before the restart).
The strange thing is that the crash seem to happen in Unity player’s function…

Here is my Activity code:

protected void onCreate (Bundle savedInstanceState)
{
        Log.d("ArenaActivity", "onCreate called; super.Oncreate.");
        super.onCreate(savedInstanceState);                  <= It crashes here
        Log.d("ArenaActivity", "onCreate called; super resolved!");
        etc...
}

And here is some log:

  • First launch (or launch after the game has been quitted):
I/ActivityManager(  473): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.thegamebakers.combocrew cmp=com.thegamebakers.combocrew/.ArenaActivity} from pid 8384
I/ActivityManager(  473): Start proc com.thegamebakers.combocrew for activity com.thegamebakers.combocrew/.ArenaActivity: pid=8919 uid=10066 gids={50066, 3003, 1028}
D/ArenaActivity( 8919): onCreate called; super.Oncreate.
D/dalvikvm( 8919): Trying to load lib /data/app-lib/com.thegamebakers.combocrew-1/libmono.so 0x41ccdd98
D/dalvikvm( 8919): Added shared lib /data/app-lib/com.thegamebakers.combocrew-1/libmono.so 0x41ccdd98
D/proxy   ( 8919): Added shared lib /assets/libs/armeabi-v7a/libmono.so 0x64f69044
D/proxy   ( 8919): No JNI_OnLoad found in /assets/libs/armeabi-v7a/libmono.so 0x64f69044
D/dalvikvm( 8919): Trying to load lib /data/app-lib/com.thegamebakers.combocrew-1/libunity.so 0x41ccdd98
D/dalvikvm( 8919): Added shared lib /data/app-lib/com.thegamebakers.combocrew-1/libunity.so 0x41ccdd98
D/proxy   ( 8919): Added shared lib /assets/libs/armeabi-v7a/libunity.so 0x64dc9044
D/libEGL  ( 8919): loaded /system/lib/egl/libEGL_tegra.so
D/libEGL  ( 8919): loaded /system/lib/egl/libGLESv1_CM_tegra.so
D/libEGL  ( 8919): loaded /system/lib/egl/libGLESv2_tegra.so
D/ArenaActivity( 8919): onCreate called; super resolved!

-Waking up the game after tap on the home button:

I/ActivityManager(  473): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.thegamebakers.combocrew/.ArenaActivity} from pid 779
D/ArenaActivity( 8919): onCreate called; super.Oncreate.
D/dalvikvm( 8919): Trying to load lib /data/app-lib/com.thegamebakers.combocrew-1/libmono.so 0x41ccdd98
D/dalvikvm( 8919): Shared lib '/data/app-lib/com.thegamebakers.combocrew-1/libmono.so' already loaded in same CL 0x41ccdd98
D/dalvikvm( 8919): Trying to load lib /data/app-lib/com.thegamebakers.combocrew-1/libunity.so 0x41ccdd98
D/dalvikvm( 8919): Shared lib '/data/app-lib/com.thegamebakers.combocrew-1/libunity.so' already loaded in same CL 0x41ccdd98
D/dalvikvm( 8919): GC_CONCURRENT freed 401K, 9% free 7848K/8576K, paused 3ms+2ms, total 25ms
D/AndroidRuntime( 8919): Shutting down VM
W/dalvikvm( 8919): threadid=1: thread exiting with uncaught exception (group=0x4157e930)
W/System.err( 8919): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}: java.lang.NullPointerException
W/System.err( 8919): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
W/System.err( 8919): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
W/System.err( 8919): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
W/System.err( 8919): 	at android.app.ActivityThread.access$600(ActivityThread.java:141)
W/System.err( 8919): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
W/System.err( 8919): 	at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 8919): 	at android.os.Looper.loop(Looper.java:137)
W/System.err( 8919): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
W/System.err( 8919): 	at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 8919): 	at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 8919): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
W/System.err( 8919): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
W/System.err( 8919): 	at dalvik.system.NativeStart.main(Native Method)
W/System.err( 8919): Caused by: java.lang.NullPointerException
W/System.err( 8919): 	at com.unity3d.player.g.a(Unknown Source)
W/System.err( 8919): 	at com.unity3d.player.g.b(Unknown Source)
W/System.err( 8919): 	at com.unity3d.player.UnityPlayer.resume(Unknown Source)
W/System.err( 8919): 	at com.unity3d.player.UnityPlayer.a(Unknown Source)
W/System.err( 8919): 	at com.unity3d.player.UnityPlayer.init(Unknown Source)
W/System.err( 8919): 	at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source)
W/System.err( 8919): 	at com.thegamebakers.combocrew.ArenaActivity.onCreate(ArenaActivity.java:28)
W/System.err( 8919): 	at android.app.Activity.performCreate(Activity.java:5104)
W/System.err( 8919): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
W/System.err( 8919): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
W/System.err( 8919): 	... 11 more
E/AndroidRuntime( 8919): FATAL EXCEPTION: main
E/AndroidRuntime( 8919): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime( 8919): Unity version     : 4.1.2f1
E/AndroidRuntime( 8919): Device model      : asus Nexus 7
E/AndroidRuntime( 8919): Device fingerprint: google/nakasi/grouper:4.2.2/JDQ39/573038:user/release-keys
E/AndroidRuntime( 8919): 
E/AndroidRuntime( 8919): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}: java.lang.NullPointerException
E/AndroidRuntime( 8919): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime( 8919): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime( 8919): 	at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime( 8919): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime( 8919): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 8919): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 8919): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 8919): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 8919): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 8919): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 8919): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 8919): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 8919): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 8919): 	at com.unity3d.player.g.a(Unknown Source)
E/AndroidRuntime( 8919): 	at com.unity3d.player.g.b(Unknown Source)
E/AndroidRuntime( 8919): 	at com.unity3d.player.UnityPlayer.resume(Unknown Source)
E/AndroidRuntime( 8919): 	at com.unity3d.player.UnityPlayer.a(Unknown Source)
E/AndroidRuntime( 8919): 	at com.unity3d.player.UnityPlayer.init(Unknown Source)
E/AndroidRuntime( 8919): 	at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source)
E/AndroidRuntime( 8919): 	at com.thegamebakers.combocrew.ArenaActivity.onCreate(ArenaActivity.java:28)
E/AndroidRuntime( 8919): 	at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime( 8919): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime( 8919): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidRuntime( 8919): 	... 11 more
W/ActivityManager(  473):   Force finishing activity com.thegamebakers.combocrew/.ArenaActivity
W/ActivityManager(  473): Activity pause timeout for ActivityRecord{420828d0 u0 com.thegamebakers.combocrew/.ArenaActivity}
W/ActivityManager(  473): Launch timeout has expired, giving up wake lock!
W/ActivityManager(  473): Activity idle timeout for ActivityRecord{420828d0 u0 com.thegamebakers.combocrew/.ArenaActivity}
W/ActivityManager(  473): Activity idle timeout for ActivityRecord{423aa990 u0 com.thegamebakers.combocrew/.ArenaActivity}
W/ActivityManager(  473): Activity destroy timeout for ActivityRecord{420828d0 u0 com.thegamebakers.combocrew/.ArenaActivity}
I/qtaguid ( 1303): Failed write_ctrl(u 31) res=-1 errno=22
I/qtaguid ( 1303): Untagging socket 31 failed errno=-22
W/NetworkManagementSocketTagger( 1303): untagSocket(31) failed with errno -22
I/ActivityThread( 1303): Acquiring provider com.android.email.provider for user 0: existing object's process dead
W/ActivityThread( 1303): Content provider com.android.email.provider.EmailProvider already published as com.android.email.provider
W/ActivityThread( 1303): Content provider com.android.email.provider.EmailProvider already published as com.android.email.notifier
I/ActivityThread( 1303): Acquiring provider com.android.email.provider for user 0: existing object's process dead
D/dalvikvm( 1303): GC_CONCURRENT freed 383K, 7% free 8040K/8576K, paused 15ms+2ms, total 53ms
W/ThrottleService(  473): unable to find stats for iface rmnet0
D/dalvikvm(  873): GC_CONCURRENT freed 496K, 8% free 8893K/9608K, paused 3ms+3ms, total 43ms
I/Process ( 8919): Sending signal. PID: 8919 SIG: 9
I/WindowState(  473): WIN DEATH: Window{423d51e8 u0 com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}
I/ActivityManager(  473): Process com.thegamebakers.combocrew (pid 8919) has died.
W/WindowManager(  473): Force-removing child win Window{42627130 u0 SurfaceView} from container Window{423d51e8 u0 com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}
W/WindowManager(  473): Failed looking up window
W/WindowManager(  473): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@42626f78 does not exist
W/WindowManager(  473): 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8102)
W/WindowManager(  473): 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8093)
W/WindowManager(  473): 	at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:932)
W/WindowManager(  473): 	at android.os.BinderProxy.sendDeathNotice(Binder.java:433)
W/WindowManager(  473): 	at dalvik.system.NativeStart.run(Native Method)
I/WindowState(  473): WIN DEATH: null

I have tried to put the crashing line in a try/catch and display the exception.getMessage(), but I got this:

D/ArenaActivity(16422): onCreate called; super.Oncreate.
D/dalvikvm(16422): Trying to load lib /data/app-lib/com.thegamebakers.combocrew-1/libmono.so 0x413e4a08
D/dalvikvm(16422): Shared lib '/data/app-lib/com.thegamebakers.combocrew-1/libmono.so' already loaded in same CL 0x413e4a08
D/dalvikvm(16422): Trying to load lib /data/app-lib/com.thegamebakers.combocrew-1/libunity.so 0x413e4a08
D/dalvikvm(16422): Shared lib '/data/app-lib/com.thegamebakers.combocrew-1/libunity.so' already loaded in same CL 0x413e4a08
D/ArenaActivity(16422): Exception on super.onCreate
D/AndroidRuntime(16422): Shutting down VM
W/dalvikvm(16422): threadid=1: thread exiting with uncaught exception (group=0x40c8d930)
W/System.err(16422): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}: java.lang.NullPointerException: println needs a message
W/System.err(16422): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
W/System.err(16422): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
W/System.err(16422): 	at android.app.ActivityThread.access$600(ActivityThread.java:141)
W/System.err(16422): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
W/System.err(16422): 	at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(16422): 	at android.os.Looper.loop(Looper.java:137)
W/System.err(16422): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
W/System.err(16422): 	at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(16422): 	at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err(16422): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
W/System.err(16422): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
W/System.err(16422): 	at dalvik.system.NativeStart.main(Native Method)
W/System.err(16422): Caused by: java.lang.NullPointerException: println needs a message
W/System.err(16422): 	at android.util.Log.println_native(Native Method)
W/System.err(16422): 	at android.util.Log.d(Log.java:138)
W/System.err(16422): 	at com.thegamebakers.combocrew.ArenaActivity.onCreate(ArenaActivity.java:34)
W/System.err(16422): 	at android.app.Activity.performCreate(Activity.java:5104)
W/System.err(16422): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
W/System.err(16422): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
W/System.err(16422): 	... 11 more
E/AndroidRuntime(16422): FATAL EXCEPTION: main
E/AndroidRuntime(16422): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime(16422): Unity version     : 4.1.2f1
E/AndroidRuntime(16422): Device model      : asus Nexus 7
E/AndroidRuntime(16422): Device fingerprint: google/nakasi/grouper:4.2.2/JDQ39/573038:user/release-keys
E/AndroidRuntime(16422): 
E/AndroidRuntime(16422): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}: java.lang.NullPointerException: println needs a message
E/AndroidRuntime(16422): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime(16422): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(16422): 	at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(16422): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(16422): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(16422): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(16422): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(16422): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(16422): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(16422): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(16422): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(16422): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(16422): Caused by: java.lang.NullPointerException: println needs a message
E/AndroidRuntime(16422): 	at android.util.Log.println_native(Native Method)
E/AndroidRuntime(16422): 	at android.util.Log.d(Log.java:138)
E/AndroidRuntime(16422): 	at com.thegamebakers.combocrew.ArenaActivity.onCreate(ArenaActivity.java:34)
E/AndroidRuntime(16422): 	at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime(16422): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime(16422): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidRuntime(16422): 	... 11 more
W/ActivityManager(  450):   Force finishing activity com.thegamebakers.combocrew/.ArenaActivity
D/dalvikvm(16422): GC_CONCURRENT freed 446K, 10% free 7843K/8624K, paused 3ms+5ms, total 34ms
W/ActivityManager(  450): Activity pause timeout for ActivityRecord{41b0d900 u0 com.thegamebakers.combocrew/.ArenaActivity}
W/ActivityManager(  450): Launch timeout has expired, giving up wake lock!
W/ActivityManager(  450): Activity idle timeout for ActivityRecord{41b0d900 u0 com.thegamebakers.combocrew/.ArenaActivity}
W/ActivityManager(  450): Activity idle timeout for ActivityRecord{4198d4b8 u0 com.thegamebakers.combocrew/.ArenaActivity}
W/ActivityManager(  450): Activity destroy timeout for ActivityRecord{41b0d900 u0 com.thegamebakers.combocrew/.ArenaActivity}
I/Process (16422): Sending signal. PID: 16422 SIG: 9
I/WindowState(  450): WIN DEATH: Window{41757278 u0 SurfaceView}
I/ActivityManager(  450): Process com.thegamebakers.combocrew (pid 16422) has died.
I/WindowState(  450): WIN DEATH: Window{414134b8 u0 com.thegamebakers.combocrew/com.thegamebakers.combocrew.ArenaActivity}

After that, I removed the “getMessage()”, and then it could finish the onCreate function, but it crashed right after that in the onResume, on the line “super.onResume();”… I surrounded this with a try/catch as well, and now it does not crash anymore, but only presents me a black screen when I try to wake up the app…

Would anyone have any idea about this? Tell me if you need further information about anything.

In case anyone would have the same problem, it appears that it only happens when the app is installed through apk file from device disk (or dropbox for example), and only when after having installed it you tap on “Open” on the pop up that is prompted (it does not happen if you tap “Ok” then open the app by tapping on its icon). So that’s a good news :slight_smile:

Sounds like a nasty bug. It might be worth trying to reproduce it with a bare-minimum project. If it happens there I’d report it to the Unity devs. The stack-trace you posted seems to imply it might be a deeper issue with Unity’s Android integration. These kinds of bugs often end up causing other obscure problems down the road. Android will do all kinds of crazy things with Activity life-cycles (which is where your crash was happening.) One test I did, the Nexus 4 was creating then destroying the activity and EGL context 3 to 4 times before showing it.

Yes, I think I’ll do it later, when I’ll have more time than right now, but I have to confess last bug report I did discouraged me a little, because I got 0 answer (despite having reproduced it in a total-minimum project and having 100% repro)…

I have the same issue…Please help me …stuck on this

I have the same issue…Please help me …stuck on this

Please include android:launchMode=“singleinstance” to your launching activity in AndroidManifest.xml file. That work for me.

I have a similar issue when using the Android 4.4 KitKat simulator - super.onCreate(savedInstanceState); causes a crash but it’s right when you start the application. It’s fine with devices and simulators using an older version of the OS.

I tried that with Unity 4.3 and 4.2 on Windows and Mac and it always resulted in a crash when using the 4.4 simulator. I tried the android:launchMode=“singleinstance” manifest change but that didn’t help either. So if anyone has other suggestions, I’d like to try them :slight_smile:

I’ve forgotten to do the crash report.
However, it’s not such a big problem, because it should never happen to people installing the game from Google Play!