简体   繁体   中英

Android beacon library compilation issues

I'm trying to make the Android Beacon Library work for a project but I'm facing a few issues.

I downloaded the library, added it to eclipse and then imported the sample project ( https://github.com/AltBeacon/android-beacon-library-reference ). Everything was working fine on Linux mint so I developped my own service based on this library.

Then I shared my code with some friends who encountered some issues on windows. Indeed, eclipse wasn't showing any errors but the apps were crashing (sample app and my own app).

So I tried to import the project on windows too and the app was crashing too. We tried this on multiple computers. I don't really understand where the errors come from. Here are the logcats :

Sample Project :

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

Own Project :

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)

As I said the app is running well when compiled from linux. I tried to modify the order of imports.

Do you have any idea where do these errors come from ?

I solved my problem by updating the ADT plugin and the SDK tools.

I updated my ADT from the 22.6 version to the 23.0.2 because I couldn't get the latest versions of the SDK tools.

Then, I installed :

  • Android SDK Tools rev 23.0.5
  • Android SDK Platform-tools rev 21
  • Android SDK Build-Tools rev 21.1.1

I also installed the Android APIs 20 and 21 but don't think that it changes anything.

Don't forget to restart eclipse and clean your workspace. I tried this on 4 computers and it worked for all of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM