Android 应用程序日志中未捕获异常的问题

发布于 2024-09-10 06:50:06 字数 2575 浏览 4 评论 0原文

当我启动我的应用程序时,我在日志中收到以下错误。你能帮我破译其中一些,并给我一个可能的解决方案吗?如果您能这样做,我将非常感激,因为事实证明这非常令人沮丧,而且我是 Android 开发的新手。我正在使用 Eclipse SDK 和 1.6 SDK 级别的 Android AVD。

谢谢..

07-17 11:05:57.046:
错误/AndroidRuntime(226):未捕获
处理程序:线程主线程由于
而退出 未捕获异常07-17
11:05:57.056:
错误/AndroidRuntime(226):
java.lang.RuntimeException:无法 开始活动
ComponentInfo{com.darius.android.distractions/com.darius.android.distractions.Distractions}: java.lang.ClassCastException:
android.widget.FrameLayout 07-17
11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.ActivityThread.access$2100(ActivityThread.java:116) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.os.Handler.dispatchMessage(Handler.java:99) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.os.Looper.loop(Looper.java:123) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.ActivityThread.main(ActivityThread.java:4203) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
java.lang.reflect.Method.invokeNative(本机 方法)07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
java.lang.reflect.Method.invoke(Method.java:521) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:791) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
dalvik.system.NativeStart.main(本机 方法)07-17 11:05:57.056:
错误/AndroidRuntime(226):原因: java.lang.ClassCastException:
android.widget.FrameLayout 07-17
11:05:57.056:
错误/AndroidRuntime(226):位于
com.darius.android.distractions.Distractions.onCreate(Distractions.java:87) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 07-17 11:05:57.056:
错误/AndroidRuntime(226):位于
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 07-17 11:05:57.056:
错误/Android运行时(226):... 11 更多

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/AndroidRuntime(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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-09-17 06:50:06

您的问题位于 Distractions 课程的第 87 行。

错误堆栈抱怨 ClassCastException,当程序尝试将对象转换为与其不兼容的类型时抛出该异常。

看起来您正在尝试将 FrameLayout 转换为它不是的东西。

解码错误堆栈的好提示,查找显示以下内容的行: Caused by: 该行将为您提供错误的原因,下面的行将向您显示错误发生的位置,并包含行引用,以便您可以轻松找到问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文