This symptoms are the same as here: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.support.v7.widget.Toolbar$SavedState
But it's not the right solution. There are no files with the same name as resource ids:
Current working dir below is app/src/main/res
:
git ls-files . | cut -d "/" -f 2 | sed 's/\.xml//g' > /tmp/a
cat values/ids.xml | cut -d "\"" -f 2 > /tmp/b
cat /tmp/a | while read line; do grep -w $line /tmp/b; done
This yields no results.
Also, there are no duplicate ids within values/ids.xml
cat values/ids.xml | cut -d "\"" -f 2 | sort | wc -l
96
cat values/ids.xml | cut -d "\"" -f 2 | sort | uniq | wc -l
96
The exception occurs when I restart the app via an Alarm.
...
alm.set(AlarmManager.RTC, System.currentTimeMillis() + 1000,
PendingIntent.getActivity(this, 0, new Intent(
this, LauncherActivity.class), 0));
Process.killProcess(Process.myPid());
...
And then it crashes before LauncherActivityies onCreate
:
java.lang.RuntimeException: Unable to start activity ComponentInfo{ba.euroexpress.izvidjac/ba.euroexpress.traffictool.android.activites.MainActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2779)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.widget.CompoundButton.onRestoreInstanceState(CompoundButton.java:563)
at android.view.View.dispatchRestoreInstanceState(View.java:17726)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3751)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3751)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3751)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3751)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3751)
at android.view.View.restoreHierarchyState(View.java:17704)
at android.support.v4.app.Fragment.restoreViewState(Fragment.java:415)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1454)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3244)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3200)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:195)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:597)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
at android.app.Activity.performStart(Activity.java:7019)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2742)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
What is causing this behavior? It happens on low memory situations and when restarting it the app in this fashion.
Also note I don't use the CompoundButton
class anywhere.
git grep CompoundButton
// no results