在android.widget.ProgressBar.onRestoreInstanceState无法解释抛出ClassCastException [英] Unexplainable ClassCastException in android.widget.ProgressBar.onRestoreInstanceState

查看:528
本文介绍了在android.widget.ProgressBar.onRestoreInstanceState无法解释抛出ClassCastException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的应用程序在商店一段时间,但似乎它崩溃偶尔根据开发者控制台,说崩溃报告: java.lang.ClassCastException在android.widget.ProgressBar.onRestoreInstanceState 的堆栈跟踪:

I've had my application out in the store for a while, but it seems it crashes occasionally according to the crash reports in the Developer Console, saying: java.lang.ClassCastException in android.widget.ProgressBar.onRestoreInstanceState with the stack trace:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.myapp/com.mycompany.myapp.activity.MyActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ProgressBar$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1996)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1174)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4503)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ProgressBar$SavedState
at android.widget.ProgressBar.onRestoreInstanceState(ProgressBar.java:1093)
at android.view.View.dispatchRestoreInstanceState(View.java:9975)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2408)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2408)
at android.view.View.restoreHierarchyState(View.java:9951)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1611)
at android.app.Activity.onRestoreInstanceState(Activity.java:908)
at android.app.Activity.performRestoreInstanceState(Activity.java:880)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1102)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
... 11 more

究其原因,这些事故逃避我,我不能复制我的任何设备。我没有一个 onRestoreInstanceState 覆盖的任何地方任。任何人都可以点我的方向是有道理的?

The reason for these crashes eludes me, and I can't reproduce it on any of my devices. I don't have a onRestoreInstanceState overridden anywhere either. Can anyone point me in a direction that makes sense?

推荐答案

我已经看到了类似的问题,这之前,它是因为你共享同一名称的两个ID的。

I've seen similar issues to this before and it's because you have two id's that share the same name.

在onRestoreInstanceState已经执行了findViewById方法和第一种观点被发现未在ProgressView。

The onRestoreInstanceState has performed the findViewById method and the first view to be found was not the ProgressView.

仔细检查您的应用程序不会重复使用相同的ID在两个不同的地方

Double check that your application does not reuse the same ID in two different places

这篇关于在android.widget.ProgressBar.onRestoreInstanceState无法解释抛出ClassCastException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆