我的应用程序不断在我的设备上生成“不幸的是应用程序已停止工作”。我查看了我的代码,看不到任何错误,但我相信我可能已经确定了我的 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;
但是我收到一条错误消息,告诉我无法解决导入问题。
我的崩溃与此导入有关吗?我该如何解决?