We are receiving crash reports like the following:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zigzagworld.icjl.tanachbible/com.zigzagworld.icjl.tanachbible.ViewTextActivity}: java.lang.RuntimeException: Parcelable encounteredClassNotFoundException reading a Serializable object (name = com.zigzagworld.icjl.tanachtext.w)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1951)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1972)
at android.app.ActivityThread.access$1500(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1048)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:846)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
. . . several other "Caused by" traces, ending with:
Caused by: java.lang.ClassNotFoundException: com.zigzagworld.icjl.tanachtext.w in loader dalvik.system.PathClassLoader[.]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
In at least one report, the user added a message indicating that the crash only happens when returning to the app after it had been paused for a significant amount of time.
From ProGuard's mapping file, I'm pretty sure which class it was that the loader could not find. It's a utility class that extends java.lang.Object
and implements Serializable
; I serialize an instance of object out when onPause
is called for ViewTextActivity
(that Android was trying to start when it crashed).
There doesn't seem to be any problem if the app is pushed to the background for a short time. Based on the symptoms, I'm guessing that the scenario is:
- The user starts
ViewTextActivity
- The user presses the Home key, receives a phone call, or does something else that pushes the app to the background
- The app remains in the background long enough that the system kills off the activity and/or the process to reclaim resources
- The user eventually returns to the app, at which point the framework tries to re-create the activity, but when it tries to read the
Bundle
that was saved when the activity was paused, it fails.
Is there a known problem reading a serialized object when the class for the object has been unloaded? Is there something else I should be looking at? Is there some sort of ProGuard problem? I think that the published app was built with the version of the Android SDK Tools that was just prior to the current version (22.3).
I should mention that we have not (yet) been able to reproduce this problem on our own test devices.