我通過Acra收到Android應用程序的錯誤報告。在我的代碼中沒有提到堆棧跟蹤中的行號。我怎麼知道問題在於我的代碼?任何人都可以幫助我。不理解Android中的java.lang.ClassCastException錯誤
堆棧跟蹤:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.itse.htsurvey/com.itse.htsurvey.Question2Page2Activity}: java.lang.ClassCastException: android.widget.CompoundButton$SavedState cannot be cast to android.widget.AbsSpinner$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3188)
at android.app.ActivityThread.access$600(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1028)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.CompoundButton$SavedState cannot be cast to android.widget.AbsSpinner$SavedState
at android.widget.AbsSpinner.onRestoreInstanceState(AbsSpinner.java:421)
at android.view.View.dispatchRestoreInstanceState(View.java:8316)
at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:2038)
at android.widget.AdapterView.dispatchRestoreInstanceState(AdapterView.java:766)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.View.restoreHierarchyState(View.java:8295)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1489)
at android.app.Activity.onRestoreInstanceState(Activity.java:898)
at android.app.Activity.performRestoreInstanceState(Activity.java:870)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1099)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1793)
... 12 more
java.lang.ClassCastException: android.widget.CompoundButton$SavedState cannot be cast to android.widget.AbsSpinner$SavedState
at android.widget.AbsSpinner.onRestoreInstanceState(AbsSpinner.java:421)
at android.view.View.dispatchRestoreInstanceState(View.java:8316)
at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:2038)
at android.widget.AdapterView.dispatchRestoreInstanceState(AdapterView.java:766)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2024)
at android.view.View.restoreHierarchyState(View.java:8295)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1489)
at android.app.Activity.onRestoreInstanceState(Activity.java:898)
at android.app.Activity.performRestoreInstanceState(Activity.java:870)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1099)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1793)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3188)
at android.app.ActivityThread.access$600(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1028)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
我的代碼com.itse.htsurvey.Question2Page2Activity:http://pastebin.com/gPYyZ0GH
編輯1:一些詳細信息 - 我想這可能是因爲一個部件編號衝突。 savedState部分表明這發生在一個活動休閒之後?這個佈局由動態添加的視圖/佈局組成,它們在運行時被賦予了id。
編輯2:只是爲了確認在所做的測試中,這是我第一次收到這個錯誤。我一直無法重現它。
編輯3:當我改變設備的方向時,我能夠重現錯誤。我如何解決這個問題?
+1的思維過程,但我還是不明白,因爲他甚至沒有在所有 –
我使用自定義的微調實現使用AbsSpinner – Rynardt