1

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 Views 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?

Brian
  • 7,955
  • 16
  • 66
  • 107
  • Are you sure tahat you are not using the same id in another resource? – Rafael Barradas Jul 25 '13 at 20:20
  • I did a file search for the id in Eclipse and found no other occurances. I also checked the R.java file just for the off chance that the same id was generate twice, and no luck there either. – Brian Jul 25 '13 at 20:23
  • Ok. The problem is really weird, because there aren't problem that you use the id to many fragments at same time. – Rafael Barradas Jul 25 '13 at 20:33
  • I know, I'm almost certain that the problem isn't actually anything to do with id's. – Brian Jul 25 '13 at 22:25
  • Some ideas for a fix could be seen here https://stackoverflow.com/q/22499272/8524 – Diederik Oct 20 '17 at 11:15

0 Answers0