屏幕旋转期间的异常:包裹:取消编组时找不到类:androidx.fragment.app.FragmentManagerState

2022-09-01 17:50:42

当屏幕旋转时,在调用:onCreate()及其超级方法:super.onCreate(savedInstanceState)期间,会出现此异常;

它似乎与此线程相关或相同:为什么当我更改屏幕方向时存在ClassNotFoundException?但不幸的是,提出的解决方案不起作用。移除广告视图不会改变任何内容。

以下是完整的堆栈:

E/Parcel: Class not found when unmarshalling: androidx.fragment.app.FragmentManagerState
    java.lang.ClassNotFoundException: androidx.fragment.app.FragmentManagerState
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at android.os.Parcel.readParcelableCreator(Parcel.java:2827)
        at android.os.Parcel.readParcelable(Parcel.java:2781)
        at android.os.Parcel.readValue(Parcel.java:2684)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3053)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
        at android.os.BaseBundle.unparcel(BaseBundle.java:232)
        at android.os.Bundle.getBundle(Bundle.java:917)
        at gh.onActivityCreated(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):32)
        at com.google.android.gms.measurement.internal.AppMeasurementDynamiteService.onActivityCreated(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):88)
        at cp.a(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):169)
        at j.onTransact(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):4)
        at android.os.Binder.transact(Binder.java:675)
        at com.google.android.gms.internal.measurement.zzq.zza(Unknown Source:20)
        at com.google.android.gms.internal.measurement.zzdp.onActivityCreated(Unknown Source:144)
        at com.google.android.gms.internal.measurement.zzex.zzgd(Unknown Source:4)
        at com.google.android.gms.internal.measurement.zzea$zzb.run(Unknown Source:11)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.ClassNotFoundException: androidx.fragment.app.FragmentManagerState
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:1346)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:1406)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:453) 
        at android.os.Parcel.readParcelableCreator(Parcel.java:2827) 
        at android.os.Parcel.readParcelable(Parcel.java:2781) 
        at android.os.Parcel.readValue(Parcel.java:2684) 
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3053) 
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288) 
        at android.os.BaseBundle.unparcel(BaseBundle.java:232) 
        at android.os.Bundle.getBundle(Bundle.java:917) 
        at gh.onActivityCreated(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):32) 
        at com.google.android.gms.measurement.internal.AppMeasurementDynamiteService.onActivityCreated(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):88) 
        at cp.a(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):169) 
        at j.onTransact(:com.google.android.gms.dynamite_measurementdynamite@17122081@17.1.22 (100400-245988633):4) 
        at android.os.Binder.transact(Binder.java:675) 
        at com.google.android.gms.internal.measurement.zzq.zza(Unknown Source:20) 
        at com.google.android.gms.internal.measurement.zzdp.onActivityCreated(Unknown Source:144) 
        at com.google.android.gms.internal.measurement.zzex.zzgd(Unknown Source:4) 
        at com.google.android.gms.internal.measurement.zzea$zzb.run(Unknown Source:11) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available 

对于 W/FA-ADS 有一个额外的警告

W/FA-Ads: Error with data collection. Data lost.
    android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.fragment.app.FragmentManagerState
        at android.os.Parcel.readParcelableCreator(Parcel.java:2917)
        at android.os.Parcel.readParcelable(Parcel.java:2843)
        at android.os.Parcel.readValue(Parcel.java:2746)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3115)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
        at android.os.BaseBundle.unparcel(BaseBundle.java:226)
        at android.os.Bundle.getBundle(Bundle.java:916)
        at kh.a(:com.google.android.gms.dynamite_measurementdynamite@19275051@19.2.75 (040408-269183835):35)
        at jz.onActivityCreated(:com.google.android.gms.dynamite_measurementdynamite@19275051@19.2.75 (040408-269183835):22)
        at com.google.android.gms.measurement.internal.AppMeasurementDynamiteService.onActivityCreated(:com.google.android.gms.dynamite_measurementdynamite@19275051@19.2.75 (040408-269183835):129)
        at cq.a(:com.google.android.gms.dynamite_measurementdynamite@19275051@19.2.75 (040408-269183835):160)
        at j.onTransact(:com.google.android.gms.dynamite_measurementdynamite@19275051@19.2.75 (040408-269183835):4)
        at android.os.Binder.transact(Binder.java:627)
        at com.google.android.gms.internal.measurement.zzb.zza(Unknown Source:20)
        at com.google.android.gms.internal.measurement.zzm.onActivityCreated(Unknown Source:144)
        at com.google.android.gms.internal.measurement.zzbd.zzf(Unknown Source:4)
        at com.google.android.gms.internal.measurement.zzz$zzb.run(Unknown Source:11)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)

答案 1

您的源代码使用 proguard 进行模糊处理。

你确定“androidx.fragment.app.FragmentManagerState”类是否被排除在proguard之外。

如果没有,请添加并尝试一下

-keep class * implements android.os.Parcelable { 
   public static final android.os.Parcelable$Creator *; 
}

答案 2

尝试添加到 中。它帮助了我。implementation 'androidx.fragment:fragment:1.2.0'build.gradle

通过提供此问题的实现消失。androidx.fragment.app.FragmentManagerState

请注意,您要使用的版本(1.2.0)可能会有所不同(较新/较旧)


推荐