RuntimeException解组未知类型代码

时间:2018-06-15 20:18:13

标签: android parcelable parcel

我的应用程序在该进程被终止并重新创建后崩溃 - 具有以下异常。

06-15 15:21:15.064 3610-3610/com.example.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.app, PID: 3610
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.ui.module.main.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@17b7cca: Unmarshalling unknown type code 1279544898 at offset 1084
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@17b7cca: Unmarshalling unknown type code 1279544898 at offset 1084
        at android.os.Parcel.readValue(Parcel.java:2824)
        at android.os.Parcel.readSparseArrayInternal(Parcel.java:3195)
        at android.os.Parcel.readSparseArray(Parcel.java:2407)
        at android.os.Parcel.readValue(Parcel.java:2802)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3114)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
        at android.os.BaseBundle.unparcel(BaseBundle.java:226)
        at android.os.Bundle.getSparseParcelableArray(Bundle.java:1009)
        at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2129)
        at android.app.Activity.onRestoreInstanceState(Activity.java:1102)
        at android.app.Activity.performRestoreInstanceState(Activity.java:1057)
        at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1260)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
06-15 15:21:15.065 3610-3610/com.example.app E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.ui.module.main.MainActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@17b7cca: Unmarshalling unknown type code 1279544898 at offset 1084
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@17b7cca: Unmarshalling unknown type code 1279544898 at offset 1084
        at android.os.Parcel.readValue(Parcel.java:2824)
        at android.os.Parcel.readSparseArrayInternal(Parcel.java:3195)
        at android.os.Parcel.readSparseArray(Parcel.java:2407)
        at android.os.Parcel.readValue(Parcel.java:2802)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3114)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
        at android.os.BaseBundle.unparcel(BaseBundle.java:226)
        at android.os.Bundle.getSparseParcelableArray(Bundle.java:1009)
        at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2129)
        at android.app.Activity.onRestoreInstanceState(Activity.java:1102)
        at android.app.Activity.performRestoreInstanceState(Activity.java:1057)
        at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1260)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

我遇到了这个看似相似的问题,accepted answer。它指出ProGuard将Parcelable实现混淆为原因,并通过添加ProGuard规则解决了该问题。

我尝试将上述ProGuard规则添加到我的ProGuard规则中,但崩溃仍然发生。我完全关闭了ProGuard,应用程序仍然崩溃。

更令人费解的是,我积极尝试避免使用Parcelable。它在一些较旧的代码库中仍然很普遍,但我尽力删除它(并实现新的ViewModel结构)。我在Parcelable中看到onRestoreInstanceState用于我创建的自定义Preference课程的唯一地方;但成功调用这些方法后会发生崩溃。堆栈跟踪似乎没有任何指向,只是MainActivity崩溃,甚至没有线号。

更新

Parcelable使用的类中引用的MainActivity的唯一用法是在自定义WallpaperPreference类中。此类用于Fragment中嵌入的MainActivity。我从活动中删除了此Fragment,但崩溃仍然发生。

0 个答案:

没有答案