I am seeing the following error on Crashlytics with a lot of incidences:
Caused by java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.widget.CompoundButton.onRestoreInstanceState(CompoundButton.java)
at android.view.View.dispatchRestoreInstanceState(View.java)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java)
at android.view.View.restoreHierarchyState(View.java)
at android.support.v4.app.Fragment.restoreViewState(Fragment.java:494)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1486)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2466)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1483)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3269)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:620)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java)
at android.app.Activity.performStart(Activity.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$900(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
However this stack trace says nothing about my codebase, since the exception is thrown at the platform level.
From what I read this might have to do with duplicate ids, but I cant find any in my code, any ideas on how to debug this?
I also tried to enable "Dont keep activities" on Developer options to force an instance restoration but I am unable to reproduce the crash manually.
onStart
restores a fragment. Do You have any fragment containingRadioButton
,Checkbox
,Switch
,ToggleButton
? If so, try to put breakpoints there and check inWatches window
if You are not casting them wrong. – PyneView
subclasses that derive fromCompoundButton
(or one of its subclasses)? – Hupp