I'm getting an exception that only occurs about 5-10% of the time when I start my app. The activity mainly contains a ScrollView
with about 20 "cards" arranged vertically (like a list). Each "card" is a Fragment
that I simply construct 20 times and add to the LinearLayout
container within the ScrollView
.
My app sometimes crashes immediately when I start it...
07-25 11:14:04.211: E/AndroidRuntime(21490): Caused by: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.ProgressBar$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/home_page_category_image. Make sure other views do not use the same id.
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.View.onRestoreInstanceState(View.java:9990)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.View.dispatchRestoreInstanceState(View.java:9966)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2622)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.view.View.restoreHierarchyState(View.java:9944)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.Fragment.restoreViewState(Fragment.java:685)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:855)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1034)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1016)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1768)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.Activity.performCreate(Activity.java:4546)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
07-25 11:14:04.211: E/AndroidRuntime(21490): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2181)
07-25 11:14:04.211: E/AndroidRuntime(21490): ... 11 more
It is true that one of the View
s in each "card" has an id tag home_page_category_image
. I've looked around and most people getting this error often have something to do with orientation changes. I specified in the manifest that this activity can only be in the portrait state. Furthermore, what's even more strange is the fact that this exception only occurs 5-10% of the time.
Does anyone know what could be causing this or how to fix it?