是什么导致 android.support.v4.app.Fragment.setUserVisibleHint() 崩溃?
What is causing crash in android.support.v4.app.Fragment.setUserVisibleHint()?
最近我在我的应用程序的 crashlytics 中看到了几次以下崩溃:
Fragment.java line 960
android.support.v4.app.Fragment.setUserVisibleHint
Fatal Exception: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.RecyclerView$SavedState
at android.os.Parcel.readParcelableCreator + 2855(Parcel.java:2855)
at android.os.Parcel.readParcelable + 2781(Parcel.java:2781)
at android.os.Parcel.readValue + 2684(Parcel.java:2684)
at android.os.Parcel.readSparseArrayInternal + 3134(Parcel.java:3134)
at android.os.Parcel.readSparseArray + 2367(Parcel.java:2367)
at android.os.Parcel.readValue + 2741(Parcel.java:2741)
at android.os.Parcel.readArrayMapInternal + 3053(Parcel.java:3053)
at android.os.BaseBundle.initializeFromParcelLocked + 288(BaseBundle.java:288)
at android.os.BaseBundle.unparcel + 232(BaseBundle.java:232)
at android.os.BaseBundle.putBoolean + 569(BaseBundle.java:569)
at android.support.v4.app.Fragment.setUserVisibleHint + 960(Fragment.java:960)
at android.support.v4.app.FragmentStatePagerAdapter.instantiateItem + 121(FragmentStatePagerAdapter.java:121)
at android.support.v4.view.ViewPager.addNewItem + 1004(ViewPager.java:1004)
at android.support.v4.view.ViewPager.populate + 1186(ViewPager.java:1186)
at android.support.v4.view.ViewPager.populate + 1086(ViewPager.java:1086)
at android.support.v4.view.ViewPager.run + 267(ViewPager.java:267)
at android.view.Choreographer$CallbackRecord.run + 986(Choreographer.java:986)
at android.view.Choreographer.doCallbacks + 764(Choreographer.java:764)
at android.view.Choreographer.doFrame + 696(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run + 965(Choreographer.java:965)
at android.os.Handler.handleCallback + 873(Handler.java:873)
at android.os.Handler.dispatchMessage + 99(Handler.java:99)
at android.os.Looper.loop + 214(Looper.java:214)
at android.app.ActivityThread.main + 7073(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)
我无法重现崩溃。
有人知道是什么原因造成的吗?
显然,崩溃是由支持兼容库之一 'com.android.support:appcompat-v7:28.0.0'
或 'com.android.support:support-compat:28.0.0'
中的错误引起的
迁移到 AndroidX
反而解决了问题。
With Android Studio 3.2 and higher, you can migrate an existing
project to AndroidX by selecting Refactor > Migrate to AndroidX from
the menu bar.
相关信息:
AndroidX replaces the original support library APIs with packages in
the androidx namespace. Only the package and Maven artifact names
changed; class, method, and field names did not change.
AndroidX is a redesigned library to make package names more clear. So
from now on android hierarchy will be for only android default
classes, which comes with android operating system and other
library/dependencies will be part of androidx (makes more sense). So
from now on all the new development will be updated in androidx.
Google 不再支持原始支持库:
Version 28.0.0 is the last release of the Support Library.
最近我在我的应用程序的 crashlytics 中看到了几次以下崩溃:
Fragment.java line 960 android.support.v4.app.Fragment.setUserVisibleHint
Fatal Exception: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.RecyclerView$SavedState
at android.os.Parcel.readParcelableCreator + 2855(Parcel.java:2855)
at android.os.Parcel.readParcelable + 2781(Parcel.java:2781)
at android.os.Parcel.readValue + 2684(Parcel.java:2684)
at android.os.Parcel.readSparseArrayInternal + 3134(Parcel.java:3134)
at android.os.Parcel.readSparseArray + 2367(Parcel.java:2367)
at android.os.Parcel.readValue + 2741(Parcel.java:2741)
at android.os.Parcel.readArrayMapInternal + 3053(Parcel.java:3053)
at android.os.BaseBundle.initializeFromParcelLocked + 288(BaseBundle.java:288)
at android.os.BaseBundle.unparcel + 232(BaseBundle.java:232)
at android.os.BaseBundle.putBoolean + 569(BaseBundle.java:569)
at android.support.v4.app.Fragment.setUserVisibleHint + 960(Fragment.java:960)
at android.support.v4.app.FragmentStatePagerAdapter.instantiateItem + 121(FragmentStatePagerAdapter.java:121)
at android.support.v4.view.ViewPager.addNewItem + 1004(ViewPager.java:1004)
at android.support.v4.view.ViewPager.populate + 1186(ViewPager.java:1186)
at android.support.v4.view.ViewPager.populate + 1086(ViewPager.java:1086)
at android.support.v4.view.ViewPager.run + 267(ViewPager.java:267)
at android.view.Choreographer$CallbackRecord.run + 986(Choreographer.java:986)
at android.view.Choreographer.doCallbacks + 764(Choreographer.java:764)
at android.view.Choreographer.doFrame + 696(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run + 965(Choreographer.java:965)
at android.os.Handler.handleCallback + 873(Handler.java:873)
at android.os.Handler.dispatchMessage + 99(Handler.java:99)
at android.os.Looper.loop + 214(Looper.java:214)
at android.app.ActivityThread.main + 7073(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)
我无法重现崩溃。
有人知道是什么原因造成的吗?
显然,崩溃是由支持兼容库之一 'com.android.support:appcompat-v7:28.0.0'
或 'com.android.support:support-compat:28.0.0'
迁移到 AndroidX
反而解决了问题。
With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
相关信息:
AndroidX replaces the original support library APIs with packages in the androidx namespace. Only the package and Maven artifact names changed; class, method, and field names did not change.
AndroidX is a redesigned library to make package names more clear. So from now on android hierarchy will be for only android default classes, which comes with android operating system and other library/dependencies will be part of androidx (makes more sense). So from now on all the new development will be updated in androidx.
Google 不再支持原始支持库:
Version 28.0.0 is the last release of the Support Library.