AltBeacon / android-beacon-library

Allows Android apps to interact with BLE beacons
Apache License 2.0
2.85k stars 837 forks source link

How to use this library for Android Instant app #1210

Closed gsg-averigo closed 1 week ago

gsg-averigo commented 2 weeks ago

Expected behavior: It should be able to detects the beacon once the instant app downloaded in the Android device

Actual behavior: The app getting crashed and giving the below exception

Steps to reproduce this behavior : Run the app as an Instant app

Mobile device model and OS version : Android 13

Android Beacon Library version : 2.20.7

Error:

 Process: (package name), PID: 8082
                                                                                                    java.lang.RuntimeException: Unable to create application  (package name) .application.Application: java.lang.IllegalArgumentException: Error: requested job be persisted without holding RECEIVE_BOOT_COMPLETED permission.
                                                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7511)
                                                                                                        at android.app.ActivityThread.access$1600(ActivityThread.java:310)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8663)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
                                                                                                    Caused by: java.lang.IllegalArgumentException: Error: requested job be persisted without holding RECEIVE_BOOT_COMPLETED permission.
                                                                                                        at android.os.Parcel.createExceptionOrNull(Parcel.java:2442)
                                                                                                        at android.os.Parcel.createException(Parcel.java:2422)
                                                                                                        at android.os.Parcel.readException(Parcel.java:2405)
                                                                                                        at android.os.Parcel.readException(Parcel.java:2347)
                                                                                                        at android.app.job.IJobScheduler$Stub$Proxy.schedule(IJobScheduler.java:312)
                                                                                                        at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:47)
                                                                                                        at org.altbeacon.beacon.service.ScanJobScheduler.schedule(ScanJobScheduler.java:205)
                                                                                                        at org.altbeacon.beacon.service.ScanJobScheduler.applySettingsToScheduledJob(ScanJobScheduler.java:96)
                                                                                                        at org.altbeacon.beacon.service.ScanJobScheduler.applySettingsToScheduledJob(ScanJobScheduler.java:103)
                                                                                                        at org.altbeacon.beacon.BeaconManager.applyChangesToServices(BeaconManager.java:1370)
                                                                                                        at org.altbeacon.beacon.BeaconManager.startMonitoringBeaconsInRegion(BeaconManager.java:1211)
                                                                                                        at org.altbeacon.beacon.BeaconManager$3.onBeaconServiceConnect(BeaconManager.java:1961)
                                                                                                        at org.altbeacon.beacon.BeaconManager.bindInternal(BeaconManager.java:463)
                                                                                                        at org.altbeacon.beacon.BeaconManager.autoBind(BeaconManager.java:1986)
                                                                                                        at org.altbeacon.beacon.BeaconManager.startMonitoring(BeaconManager.java:1251)
                                                                                                        at com.grabscango.shop.application.AverigoApp.bindBeaconService(AverigoApp.kt:176)
                                                                                                        at com.grabscango.shop.application.AverigoApp.setupBeaconManager(AverigoApp.kt:120)
                                                                                                        at com.grabscango.shop.application.AverigoApp.onCreate(AverigoApp.kt:91)
                                                                                                        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
                                                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7506)
                                                                                                        at android.app.ActivityThread.access$1600(ActivityThread.java:310) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226) 
                                                                                                        at android.os.Looper.loop(Looper.java:313) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8663) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 
                                                                                                    Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                        at com.android.server.job.JobSchedulerService$JobSchedulerStub.schedule(JobSchedulerService.java:2761)
                                                                                                        at android.app.job.IJobScheduler$Stub.onTransact(IJobScheduler.java:155)
                                                                                                        at android.os.Binder.execTransactInternal(Binder.java:1215)
                                                                                                        at android.os.Binder.execTransact(Binder.java:1179)
davidgyoung commented 1 week ago

Unfortunately, Android does not support Bluetooth scanning for instant apps, so I am afraid this is impossible. Sorry.