2

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:

  1. The user starts ViewTextActivity
  2. The user presses the Home key, receives a phone call, or does something else that pushes the app to the background
  3. The app remains in the background long enough that the system kills off the activity and/or the process to reclaim resources
  4. 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.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • Sounds similar to [this one](http://stackoverflow.com/a/6780028/752320). Are you letting ProGuard change your serializable class names (appears that way from the log, but...)? I'm not sure why this would only happen when unloaded, but the OP on that one couldn't duplicate in normal situations either. – Geobits Nov 19 '13 at 23:19
  • @Geobits - Yes, it looks exactly like that one. Thanks. I'm going to try that solution, but it looks like my question is a duplicate. Just out of curiosity: how did you find that thread? I searched quite a bit on SO and somehow I missed it. – Ted Hopp Nov 19 '13 at 23:24
  • Google searched for "serializable classnotfoundexception", oldest trick in the book ;) – Geobits Nov 19 '13 at 23:27

0 Answers0