MFPAnalytics.logApplicationStartup(); causes NPE
Closed this issue · 3 comments
drcariel commented
02-17 15:54:26.957 18654-18654/com.ibm.picafeteria E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ibm.picafeteria, PID: 18654
java.lang.RuntimeException: Unable to resume activity {com.ibm.picafeteria/com.ibm.picafeteria.StationActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.optInt(java.lang.String)' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2974)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.optInt(java.lang.String)' on a null object reference
at com.ibm.mobilefirstplatform.clientsdk.android.analytics.api.MFPAnalytics.logApplicationStartup(MFPAnalytics.java:139)
at com.ibm.picafeteria.MainActivity.onStart(MainActivity.java:132)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
at android.app.Activity.performStart(Activity.java:6036)
at android.app.Activity.performRestart(Activity.java:6093)
at android.app.Activity.performResume(Activity.java:6098)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2963)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3005)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1328)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
dgonz7 commented
Can you put a code snippet of the code around line 132 in your Main Activity? That is where it is crashing and it will be helpful to have context.
dgonz7 commented
Ok I think I figured it out. Make sure that in your onCreate you call startLoggingApplicationStartup(). The reason it is failing is that that method wasn’t called. I’ll fix the error handling so that it gives a more useful message.
dgonz7 commented
This was fixed in v2, closing this.