我试图让Android Beacon Library适用于某个项目,但我遇到了一些问题。
我下载了库,将其添加到eclipse,然后导入了示例项目(https://github.com/AltBeacon/android-beacon-library-reference)。在Linux薄荷上一切都运行良好,所以我基于这个库开发了自己的服务。
然后我与一些在Windows上遇到问题的朋友分享了我的代码。事实上,eclipse并没有显示任何错误,但应用程序崩溃了(示例应用程序和我自己的应用程序)。
所以我试图在Windows上导入项目,应用程序也崩溃了。我们在多台计算机上试过这个。我真的不明白错误的来源。这是logcats:
示例项目:
11-28 22:23:17.089: D/AndroidRuntime(7145): Shutting down VM
11-28 22:23:17.089: W/dalvikvm(7145): threadid=1: thread exiting with uncaught exception (group=0x41569ba8)
11-28 22:23:17.099: E/AndroidRuntime(7145): FATAL EXCEPTION: main
11-28 22:23:17.099: E/AndroidRuntime(7145): Process: org.altbeacon.beaconreference, PID: 7145
11-28 22:23:17.099: E/AndroidRuntime(7145): java.lang.RuntimeException: Unable to instantiate application org.altbeacon.beaconreference.BeaconReferenceApplication: java.lang.ClassNotFoundException: Didn't find class "org.altbeacon.beaconreference.BeaconReferenceApplication" on path: DexPathList[[zip file "/data/app/org.altbeacon.beaconreference-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.altbeacon.beaconreference-1, /vendor/lib, /system/lib]]
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4317)
11-28 22:23:17.099: E/AndroidRuntime(7145): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
11-28 22:23:17.099: E/AndroidRuntime(7145): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.ActivityThread.handleBindApplication(Native Method)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.os.Handler.dispatchMessage(Handler.java:102)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.os.Looper.loop(Looper.java:136)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-28 22:23:17.099: E/AndroidRuntime(7145): at java.lang.reflect.Method.invokeNative(Native Method)
11-28 22:23:17.099: E/AndroidRuntime(7145): at java.lang.reflect.Method.invoke(Method.java:515)
11-28 22:23:17.099: E/AndroidRuntime(7145): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-28 22:23:17.099: E/AndroidRuntime(7145): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-28 22:23:17.099: E/AndroidRuntime(7145): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
11-28 22:23:17.099: E/AndroidRuntime(7145): at dalvik.system.NativeStart.main(Native Method)
11-28 22:23:17.099: E/AndroidRuntime(7145): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.altbeacon.beaconreference.BeaconReferenceApplication" on path: DexPathList[[zip file "/data/app/org.altbeacon.beaconreference-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.altbeacon.beaconreference-1, /vendor/lib, /system/lib]]
11-28 22:23:17.099: E/AndroidRuntime(7145): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-28 22:23:17.099: E/AndroidRuntime(7145): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
11-28 22:23:17.099: E/AndroidRuntime(7145): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.Instrumentation.newApplication(Instrumentation.java:975)
11-28 22:23:17.099: E/AndroidRuntime(7145): at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
11-28 22:23:17.099: E/AndroidRuntime(7145): ... 15 more
自有项目:
11-28 22:29:05.230: I/dalvikvm(8591): Failed resolving Lcom/eirb/projets9/scanner/RangingService; interface 772 'Lorg/altbeacon/beacon/BeaconConsumer;'
11-28 22:29:05.230: W/dalvikvm(8591): Link of class 'Lcom/eirb/projets9/scanner/RangingService;' failed
11-28 22:29:05.230: E/dalvikvm(8591): Could not find class 'com.eirb.projets9.scanner.RangingService', referenced from method com.eirb.projets9.MainActivity.onCreate
11-28 22:29:05.230: W/dalvikvm(8591): VFY: unable to resolve const-class 673 (Lcom/eirb/projets9/scanner/RangingService;) in Lcom/eirb/projets9/MainActivity;
11-28 22:29:05.230: D/dalvikvm(8591): VFY: replacing opcode 0x1c at 0x000f
11-28 22:29:05.280: D/AndroidRuntime(8591): Shutting down VM
11-28 22:29:05.280: W/dalvikvm(8591): threadid=1: thread exiting with uncaught exception (group=0x41569ba8)
11-28 22:29:05.280: E/AndroidRuntime(8591): FATAL EXCEPTION: main
11-28 22:29:05.280: E/AndroidRuntime(8591): Process: com.eirb.projets9, PID: 8591
11-28 22:29:05.280: E/AndroidRuntime(8591): java.lang.NoClassDefFoundError: com.eirb.projets9.scanner.RangingService
11-28 22:29:05.280: E/AndroidRuntime(8591): at com.eirb.projets9.MainActivity.onCreate(MainActivity.java:56)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.Activity.performCreate(Activity.java:5231)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.os.Handler.dispatchMessage(Handler.java:102)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.os.Looper.loop(Looper.java:136)
11-28 22:29:05.280: E/AndroidRuntime(8591): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-28 22:29:05.280: E/AndroidRuntime(8591): at java.lang.reflect.Method.invokeNative(Native Method)
11-28 22:29:05.280: E/AndroidRuntime(8591): at java.lang.reflect.Method.invoke(Method.java:515)
11-28 22:29:05.280: E/AndroidRuntime(8591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-28 22:29:05.280: E/AndroidRuntime(8591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-28 22:29:05.280: E/AndroidRuntime(8591): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
11-28 22:29:05.280: E/AndroidRuntime(8591): at dalvik.system.NativeStart.main(Native Method)
正如我所说,从linux编译时应用程序运行良好。我试图修改导入的顺序。
你知道这些错误来自哪里吗?
答案 0 :(得分:0)
我通过更新ADT插件和SDK工具解决了我的问题。
我将ADT从22.6版本更新到23.0.2,因为我无法获得最新版本的SDK工具。
然后,我安装了:
我还安装了Android API 20和21,但不认为它会改变任何内容。
不要忘记重新启动eclipse并清理工作区。我在4台计算机上试过它,它适用于所有这些计算机。