AltBeacon library - how to use in a remote service

I am trying to use the AltBeacon library with a ranking function in a remote service. However, it has not yet been able to start beacon detection. When declaring the same service as the local service, everything works fine.

When a service starts in its own process, the startRangingBeaconsInRegion () function seems to throw the following exception:

09-17 17:09:14.643  10709-10729/com.my.project E/Parcel﹕ Class not found when unmarshalling: org.altbeacon.beacon.service.StartRMData
    java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:309)
            at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
            at android.os.Parcel.readParcelable(Parcel.java:2245)
            at android.os.Message.readFromParcel(Message.java:571)
            at android.os.Message.access$000(Message.java:32)
            at android.os.Message$1.createFromParcel(Message.java:527)
            at android.os.Message$1.createFromParcel(Message.java:524)
            at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
            at android.os.Binder.execTransact(Binder.java:446)
     Caused by: java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:309)
            at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
            at android.os.Parcel.readParcelable(Parcel.java:2245)
            at android.os.Message.readFromParcel(Message.java:571)
            at android.os.Message.access$000(Message.java:32)
            at android.os.Message$1.createFromParcel(Message.java:527)
            at android.os.Message$1.createFromParcel(Message.java:524)
            at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
            at android.os.Binder.execTransact(Binder.java:446)
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
09-17 17:09:14.643  10709-10729/com.my.project W/Binder﹕ Caught a RuntimeException from the binder stub implementation.
    android.os.BadParcelableException: ClassNotFoundException when unmarshalling: org.altbeacon.beacon.service.StartRMData
            at android.os.Parcel.readParcelableCreator(Parcel.java:2295)
            at android.os.Parcel.readParcelable(Parcel.java:2245)
            at android.os.Message.readFromParcel(Message.java:571)
            at android.os.Message.access$000(Message.java:32)
            at android.os.Message$1.createFromParcel(Message.java:527)
            at android.os.Message$1.createFromParcel(Message.java:524)
            at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
            at android.os.Binder.execTransact(Binder.java:446)

Is there any solution to this problem?

+4
source share
2 answers
+1

, , , . , Beacon , , altBeacon , . BeaconManager :

<!-- This is our own BeaconService. We run it in own process, as we don't want it affecting UI, and better crash control.
   This also solves the ACRA issue. -->
<service android:name=".BeaconControllerService"
         android:process=":my.BeaconControllerService"
         android:exported="false"
         android:enabled="true">

</service>

<!-- Override beacon library. Set it to our process -->

<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver"
          android:process=":my.BeaconControllerService"
          tools:replace="process" />
<service
    android:name="org.altbeacon.beacon.service.BeaconService"
    android:process=":my.BeaconControllerService"
    tools:replace="process" />
<service
    android:name="org.altbeacon.beacon.BeaconIntentProcessor"
    android:process=":my.BeaconControllerService"
    tools:replace="process" />

. ACRA. , , , Message AIDL. . Android. , BeaconManager Service, .

+1

Source: https://habr.com/ru/post/1607868/


All Articles