Android应用程序在运行时和导入问题时不断崩溃

时间:2013-09-06 13:51:57

标签: android

我的应用程序一直在我的设备上生成“不幸的应用已停止工作”。我查看了我的代码并且看不到任何错误,但我相信我可能已经确定了我的logcat文件抱怨的内容。

这是我的logcat:

    09-06 14:38:20.974: D/AndroidRuntime(28710): Shutting down VM
09-06 14:38:20.974: W/dalvikvm(28710): threadid=1: thread exiting with uncaught exception (group=0x41573700)
09-06 14:38:20.974: E/AndroidRuntime(28710): FATAL EXCEPTION: main
09-06 14:38:20.974: E/AndroidRuntime(28710): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.bluetooth.le/com.example.bluetooth.le.DeviceScanActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.bluetooth.le.DeviceScanActivity" on path: DexPathList[[zip file "/data/app/com.example.bluetooth.le-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.bluetooth.le-1, /vendor/lib, /system/lib]]
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.os.Looper.loop(Looper.java:137)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.ActivityThread.main(ActivityThread.java:5103)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at java.lang.reflect.Method.invokeNative(Native Method)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at java.lang.reflect.Method.invoke(Method.java:525)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at dalvik.system.NativeStart.main(Native Method)
09-06 14:38:20.974: E/AndroidRuntime(28710): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.bluetooth.le.DeviceScanActivity" on path: DexPathList[[zip file "/data/app/com.example.bluetooth.le-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.bluetooth.le-1, /vendor/lib, /system/lib]]
09-06 14:38:20.974: E/AndroidRuntime(28710):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
09-06 14:38:20.974: E/AndroidRuntime(28710):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
09-06 14:38:20.974: E/AndroidRuntime(28710):    ... 11 more

我有一种强烈的感觉,它会抱怨这种导入:

import com.example.bluetooth.le.R;

我认为导入停止生成该错误我的应用程序名称应该代替.le。所以在我的情况下它会显示:

import com.example.bluetooth.samplebletest.R;

但是我收到错误告诉我导入无法解决。

我的崩溃与此导入有关吗?我该如何解决?

1 个答案:

答案 0 :(得分:1)

检查以下内容:

  1. 您的Android项目将com.example.bluetooth.le声明为library项目属性 - > Android->图书馆+
  2. 正在导出Android依赖项。 项目属性 - > Java构建路径 - >订单和导出
  3. 您在项目中使用的活动位于项目清单中。
  4. 最后验证您尝试创建的Activity实际上是否包含在库apk中,而不仅仅是在编译期间用于解析的jar。