【问题标题】:Trouble with Android App Uncaught Exceptions in the Log日志中 Android 应用程序未捕获异常的问题
【发布时间】:2010-07-17 11:16:11
【问题描述】:

当我启动我的应用程序时,我在日志中收到以下错误。谁能帮我破译其中一些,并给我一个潜在的解决方案?如果你能证明它非常令人沮丧,我将不胜感激,而且我是 Android 开发的新手。我在 1.6 SDK 级别使用带有 Android AVD 的 Eclipse SDK。

谢谢..

07-17 11:05:57.046:
错误/AndroidRuntime(226):未捕获
处理程序:线程主因
而退出 未捕获的异常 07-17
11:05:57.056:
错误/AndroidRuntime(226):
java.lang.RuntimeException:无法 开始活动
组件信息{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(Native 方法) 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(Native 方法) 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:
错误/AndroidRuntime(226): ... 11 更多

【问题讨论】:

    标签: android eclipse avd


    【解决方案1】:

    您的问题在 Distractions 课程的第 87 行。

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

    看起来您正试图将 FrameLayout 转换为不是的。

    解码错误堆栈的好提示,查找“Caused by”行:此行将为您提供错误原因,下面的行将显示错误发生的位置,并将包含行参考,以便您可以轻松找到问题。

    【讨论】:

      猜你喜欢
      • 2020-11-28
      • 2021-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-28
      • 2012-09-07
      • 2011-10-07
      相关资源
      最近更新 更多