Trouble with Android App Uncaught Exceptions in the Log
When I launch my app I get the following errors in the log. Can you anyone decipher some of them for me, and give me a potential solution? I would be so grateful if you could as its proving very frustrating and I am new to Android development. I am using Eclipse SDK with an Android AVD at 1.6 SDK level.
Thanks..
07-17 11:05:57.046:
ERROR/AndroidRuntime(226): Uncaught handler: thread main exiting due to uncaught exception 07-17 11:05:57.056: ERROR/AndroidRuntime(226): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.darius.android.distractions/com.darius.android.distractions.Distractions}: java.lang.ClassCastException: android.widget.FrameLayout 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.os.Handler.dispatchMessage(Handler.java:99) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.os.Looper.loop(Looper.java:123) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.app.ActivityThread.main(ActivityThread.java:4203) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at java.lang.reflect.Method.invokeNative(Native Method) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at java.lang.reflect.Method.invoke(Method.java:521) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:791) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at dalvik.system.NativeStart.main(Native Method) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): Caused by: java.lang.ClassCastException: android.widget.FrameLayout 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at com.darius.android.distractions.Distractions.onCreate(Distractions.java:87) 07-17 11:05:57.056: ERROR/AndroidRun开发者_开发技巧time(226): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 07-17 11:05:57.056: ERROR/AndroidRuntime(226): ... 11 more
Your problem is on line 87 of your Distractions class.
The error stack complaining of a ClassCastException which is thrown when a program attempts to cast an object to a type with which it is not compatible.
It looks like you are trying to cast a FrameLayout as something it is not.
Good tip for decoding the error stack, look for the line that says Caused by: This line will give you a reason for the error and the line below will show you where the error is happening and will include a line reference so you can easily find the problem.
精彩评论