Android ViewGroup 子布局Layout id重名导致某些设备出现中断问题

最近看了一下友盟的异常日志,发现很多类型转换异常导致程序中断,看了代码,感觉这些错误也挺莫名其妙的,看不到直接引起异常的代码,唯一可疑的是最近在某一子Layout调整了@+id/loadingLayout 指向节点,但输出报时已经build过了,编译也正常,实在不解,为何在某些设备上就会转换失败。得找一台设备测试下。

临时解决方法:重命名@+id,避免跟其它layout中的节点命名重,

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/loadingLayout. Make sure other views do not use the same id.


       --------- beginning of /dev/log/system
--------- beginning of /dev/log/main
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com. /com.kdweibo.activities.ACT_ }: 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/loadingLayout. 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.access$1500(ActivityThread.java:117)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:130)
	at android.app.ActivityThread.main(ActivityThread.java:3687)
	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:867)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
	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/loadingLayout. Make sure other views do not use the same id.
	at android.view.View.onRestoreInstanceState(View.java:6302)
	at android.view.View.dispatchRestoreInstanceState(View.java:6278)
	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.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
	at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1215)
	at android.view.View.restoreHierarchyState(View.java:6257)
	at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1552)
	at android.app.Activity.onRestoreInstanceState(Activity.java:844)
	at android.app.Activity.performRestoreInstanceState(Activity.java:816)
	at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1629)
	... 11 more

                



       

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值