1

My App crashes when trying to open the app chooser to display a PDF. The crash seems to be in a class defined in an app dependency library. The strange thing is the class T4PushAuthentication apparently has nothing to do with the call. Still, it is a member of the calling activity This is the code snipped causing the crash:

Intent target = new Intent(Intent.ACTION_VIEW);

Uri fileUri = T4IDAppFileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".utils.provider", file);
target.setDataAndType( fileUri, T4Keys.APPLICATION_PDF);
target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

Intent chooserIntent = Intent.createChooser(target, "Open File");
chooserIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.startActivity(chooserIntent);

The crash happens when executing the last line of code.

This is the stack trace I get:

02-12 11:19:34.154 9506-9506/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: android:ui, PID: 9506
    java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.ChooserActivity}: java.lang.RuntimeException: Parcelable encountered ClassNotFoundException reading a Serializable object (name = com.intesigroup.time4eid.sdk.v2.models.T4PushAuthentication)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
        at android.os.Handler.dispatchMessage(Handler.java:111)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5728)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
     Caused by: java.lang.RuntimeException: Parcelable encountered ClassNotFoundException reading a Serializable object (name = com.intesigroup.time4eid.sdk.v2.models.T4PushAuthentication)
        at android.os.Parcel.readSerializable(Parcel.java:2491)
        at android.os.Parcel.readValue(Parcel.java:2294)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:2592)
        at android.os.BaseBundle.unparcel(BaseBundle.java:221)
        at android.os.Bundle.getParcelable(Bundle.java:786)
        at android.content.Intent.getParcelableExtra(Intent.java:5575)
        at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:132)
        at android.app.Activity.performCreate(Activity.java:6314)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488) 
        at android.os.Handler.dispatchMessage(Handler.java:111) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:5728) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
     Caused by: java.lang.ClassNotFoundException: com.intesigroup.time4eid.sdk.v2.models.T4PushAuthentication
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:324)
        at android.os.Parcel$2.resolveClass(Parcel.java:2477)
        at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1641)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:657)
        at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1782)
        at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
        at android.os.Parcel.readSerializable(Parcel.java:2485)
        at android.os.Parcel.readValue(Parcel.java:2294) 
        at android.os.Parcel.readArrayMapInternal(Parcel.java:2592) 
        at android.os.BaseBundle.unparcel(BaseBundle.java:221) 
        at android.os.Bundle.getParcelable(Bundle.java:786) 
        at android.content.Intent.getParcelableExtra(Intent.java:5575) 
        at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:132) 
        at android.app.Activity.performCreate(Activity.java:6314) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488) 
        at android.os.Handler.dispatchMessage(Handler.java:111) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:5728) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.intesigroup.time4eid.sdk.v2.models.T4PushAuthentication" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:324) 
        at android.os.Parcel$2.resolveClass(Parcel.java:2477) 
        at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1641) 
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:657) 
        at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1782) 
        at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:761) 
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983) 
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940) 
        at android.os.Parcel.readSerializable(Parcel.java:2485) 
        at android.os.Parcel.readValue(Parcel.java:2294) 
        at android.os.Parcel.readArrayMapInternal(Parcel.java:2592) 
        at android.os.BaseBundle.unparcel(BaseBundle.java:221) 
        at android.os.Bundle.getParcelable(Bundle.java:786) 
        at android.content.Intent.getParcelableExtra(Intent.java:5575) 
        at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:132) 
        at android.app.Activity.performCreate(Activity.java:6314) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488) 
        at android.os.Handler.dispatchMessage(Handler.java:111) 
        at android.os.Looper.loop(Looper.java:207) 
        at android.app.ActivityThread.main(ActivityThread.java:5728) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
        Suppressed: java.lang.ClassNotFoundException: com.intesigroup.time4eid.sdk.v2.models.T4PushAuthentication
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                ... 29 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

EDIT: The problem seems to be the T4PushAuthentication member class in the calling activity. Looks like the callee serialises the member, and doesn't find the class information when trying to deserialise it. How may I provide such information? Am I missing something?

FrizzTheSnail
  • 1,048
  • 11
  • 21
  • I think the main Error is "java.lang.ClassNotFoundException: Didn't find class "com.intesigroup.time4eid.sdk.v2.models.T4PushAuthentication" – emandt Feb 12 '19 at 11:35
  • @emandt yes, looks like that is the problem, but how can I fix it? The class is visible and widely used in my app. – FrizzTheSnail Feb 12 '19 at 12:03
  • Please provide FULL stacktrace error without the "... 29 more" collapsed row. I think the ClassLoader cannot load/find that class in current Path. Please check for this: https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – emandt Feb 12 '19 at 12:40

1 Answers1

0

I found the bug, actually it was in the activity class itself: it had an overload in for the startActivity member, which packed the T4PushAuthentication object into the intent :(

FrizzTheSnail
  • 1,048
  • 11
  • 21