onRestoreInstanceState中IllegalArgumentException的原因是什么

时间:2017-05-25 08:21:09

标签: android

我的Google Play控制台中报告了多次(超过10次)崩溃,并显示此堆栈跟踪(已完整):

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
  at android.app.ActivityThread.access$600(ActivityThread.java:141)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5103)
  at java.lang.reflect.Method.invokeNative(Native Method:0)
  at java.lang.reflect.Method.invoke(Method.java:525)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.IllegalArgumentException: 
  at android.view.View.onRestoreInstanceState(View.java:12308)
  at android.view.View.dispatchRestoreInstanceState(View.java:12284)
  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2617)
  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2623)
  at android.view.View.restoreHierarchyState(View.java:12262)
  at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1647)
  at android.app.Activity.onRestoreInstanceState(Activity.java:938)
  at android.app.Activity.performRestoreInstanceState(Activity.java:910)
  at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2189)

什么会触发此异常?堆栈跟踪中没有提到我的应用程序类。我该怎么办?

1 个答案:

答案 0 :(得分:0)

以下文字写在View.java:12308的Android源代码中,作为IllegalArgumentException消息:

错误的州级,期待View State但收到(别的东西)。当两个不同类型的视图在同一层次结构中具有相同的id时,通常会发生这种情况。该视图的id是(view id)。确保其他视图不使用相同的ID。