title: Android: duplicated ids in view hierarchy
body: <p>I have a problem, reported from the market - huge crash in the app, telling me that:</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity ComponentInfo{com....android/com....android.activities....}: 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/0x2. Make sure other views do not use the same id.</p>
  </blockquote>
  
  <p>So I know it usually means what it says - I have somewhere views with duplicated ids. This is good, but what worries me is that I think the duplicated id views come with some <strong>ad</strong> network I have integrated. I tried to contain the crash with try/catch on the view, that holds every ad, but it failed to catch it.</p>
  
  <p>So my next thought is that the ad views still have some role in this, but the crash occures on the other (my own) view, that has the same id. The thing is, I don't know what is that view and where to search for it. Do you have any ideas what can be a view with id 0x2? (also 0x3 - lots of reports on that id too)? Have you stumbled on similar crash, connected with ad networks?</p>
  
  <p>Really frustrated over this. Any help appreciated!</p>
  
  <p>Thanks,
  Dan</p>
  
  <p>PS the full stack trace:</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.....android/com.....android.activities....}: 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/0x2. Make sure other views do not use the same id.
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836)
    at android.app.ActivityThread.access$1600(ActivityThread.java:117)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
    at dalvik.system.NativeStart.main(Native Method)
    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/0x2. Make sure other views do not use the same id.
    at android.view.View.onRestoreInstanceState(View.java:6355)
    at android.view.View.dispatchRestoreInstanceState(View.java:6331)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1211)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
    at android.view.View.restoreHierarchyState(View.java:6310)
    at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1537)
    at android.app.Activity.onRestoreInstanceState(Activity.java:850)
    at android.app.Activity.performRestoreInstanceState(Activity.java:822)
    at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1629)
    ... 12 more</p>
  </blockquote>