0
\$\begingroup\$

I have just launched a game on the Playstore with Unity IAP 1.19.0 . Everything worked fine during the internal tests though last week I got a crash report from Crashlytics that I have difficulty analyzing. Any help on finding the root cause would be really appreciated. Here is an extract from the trace:

Fatal Exception: java.lang.Error: FATAL EXCEPTION [main]
Unity version     : 5.5.4p3
OS Version: 7.1.1
Device: Nexus 6

Caused by java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abc.abcd/com.unity.purchasing.googleplay.PurchaseActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.BaseBundle.getString(java.lang.String)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.BaseBundle.getString(java.lang.String)' on a null object reference
at com.unity.purchasing.googleplay.PurchaseActivity.onCreate(PurchaseActivity.java:41)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
\$\endgroup\$
  • \$\begingroup\$ You clearly have a null pointer exception, meaning that the object you're trying to use is null ( it doesn't exist ). Make sure you catch these errors so debugging becomes easier. Also use logcat and add a few prints. Alternatively create the android project and debug in android studio. \$\endgroup\$ – Sidar Jun 18 '18 at 11:36
  • \$\begingroup\$ Thanks @Sidar. The problem is that, as I said, internal tests didn't manage to reproduce the error and the call to com.unity.purchasing.googleplay.PurchaseActivity.onCreate is not made directly from my code, it is a bit of a black box :( \$\endgroup\$ – Frank S Jun 18 '18 at 12:22
  • \$\begingroup\$ You should validate if every context is created and even use try catch. Could it be that you eliminate code for deployment builds? \$\endgroup\$ – Sidar Jun 18 '18 at 12:34
  • 1
    \$\begingroup\$ This may be a lower level problem than your code. I've had these on rare occasion and seen them stemming from the com.android.internal.os.ZygoteInit calls from Android with a Unity app. You should read more about them, but from my reading they're java language calls in android to make relaunching an app from sleep faster. Some forums I read stated that after updating Unity from version X to X+1 cleared them up. \$\endgroup\$ – Tartle Wizard Jun 19 '18 at 15:58
  • \$\begingroup\$ Thanks @TartleWizard I had a look at what you suggested and it seems to fit with what I have observed. \$\endgroup\$ – Frank S Jun 25 '18 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.