屏幕旋转期间发生异常:地块:解组时找不到类:androidx.fragment.app.FragmentManagerState

时间:2019-05-24 09:27:31

标签: java android android-fragments admob

在调用onCreate()及其超级方法super.onCreate(savedInstanceState);的过程中,屏幕旋转时会出现此异常。

它似乎与此线程相关或相同:Why is there ClassNotFoundException when i change screen orientation? 但不幸的是,建议的解决方案不起作用。删除AdView不会改变任何内容。

这是完整的堆栈:

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/Ads: Error with data collection. Data lost.
    android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.fragment.app.FragmentManagerState
        at android.os.Parcel.readParcelableCreator(Parcel.java:2855)
        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)

3 个答案:

答案 0 :(得分:0)

您的源代码已使用proguard进行了混淆。

确定要从proguard中排除“ androidx.fragment.app.FragmentManagerState”类。

如果没有,请添加并尝试

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

答案 1 :(得分:0)

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

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

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

答案 2 :(得分:0)

我有这个例外,花了我一段时间才弄清楚发生了什么。我认为我的情况与@ Amirr0r在他的评论中提到的情况完全相同,因此可能值得在此处进行报告。 关键是在Logcat窗口中显示所有带有“ 没有过滤器”的内容。在这个奇怪的异常之前,应该有一个崩溃的异常或ANR。就我而言,这是由前台服务引起的ANR。一旦解决了ANR,这个问题就解决了。