0

This is the strangest thing ever.

I have an Android app that was working fine on 3 of my test devices until yesterday. I know for a fact that I didn't change anything that could possibly cause what I am seeing now.

But,

Every time I run it on the Samsung Galaxy Tab Model GT-P5100 it gets to this Activity where it crashes consistently. With;

java.lang.NullPointerException
at android.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1542)
at android.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1572)
at android.app.Activity.onSaveInstanceState(Activity.java:1164)
at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:522)
at android.app.Activity.performSaveInstanceState(Activity.java:1113)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1189)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2807)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2865)
at android.app.ActivityThread.access$900(ActivityThread.java:128)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1178)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)

The strange thing is that it happens regardless of what I do on the activity. Whether I click on the app "Up" button, toolbar menus, select something in the list, touch random places on the screen e.t.c.

The stacktrace shows not a single line of my code and non of the break points I set, even on onSaveInstanceState get hit. I've seen similar issues described in several places, including here and here and here, but none has quite helped, especially seeing that this exact device was running fine right until yesterday.

I am running v13 support library revision 23.1.1 and that's as up to date as can be. The tablet is running Android 4.0.3.

My other test devices are both Samsung phones on Android 4.2 and up and they are all running perfectly fine.

Any help will be much appreciated. Thanks!

Community
  • 1
  • 1
Gitahi Ng'ang'a
  • 901
  • 3
  • 10
  • 23

1 Answers1

1

Well, I was looking for the problem where it wasn't. The problem wasn't on the activity I was starting but rather the one I was leaving. It just so happened that the crash happened long enough after the switch over that it seemed to be occurring randomly in the new activity. Talk about superstition!

So what was the problem?

I still don't understand it, but what I found was the preceding activity was throwing an NPE on the onSaveInstanceState() method only on this particular device/android version and not the rest. So I simply put the implementation in a try-catch block and I was good to go.

I do not know why the issue started occurring suddenly, as it hadn't been there all a long.

Gitahi Ng'ang'a
  • 901
  • 3
  • 10
  • 23