我有一次这个logcat错误。这次我从非Activity子类开始一个新的Activity。启动的新Activity是空的,因此它与内容无关。
以下是logcat行:
01-14 11:11:03.562: ERROR/AndroidRuntime(299): Uncaught handler: thread main exiting due to uncaught exception
01-14 11:11:03.702: ERROR/AndroidRuntime(299): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.JDL.Apps.Snake/com.JDL.Apps.Snake.SettingsScreen}: java.lang.ClassCastException: com.JDL.Apps.Snake.SettingsScreen
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.os.Looper.loop(Looper.java:123)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at java.lang.reflect.Method.invokeNative(Native Method)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at java.lang.reflect.Method.invoke(Method.java:521)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at dalvik.system.NativeStart.main(Native Method)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): Caused by: java.lang.ClassCastException: com.JDL.Apps.Snake.SettingsScreen
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
答案 0 :(得分:1)
Caused by: java.lang.ClassCastException: com.JDL.Apps.Snake.SettingsScreen 01-14 11:11:03.702: ERROR/AndroidRuntime(299): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
简而言之,你有一个类强制转换异常。