question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BeaconManager#unbind throws IllegalArgumentException

See original GitHub issue

Sometimes, Beaconmanager#unbind throws an IllegalArgumentException:

Caused by: java.lang.IllegalArgumentException: Service not registered: org.altbeacon.beacon.BeaconManager$1@b639ead
1   android.app.LoadedApk.forgetServiceDispatcher   LoadedApk.java, line 1029
2   android.app.ContextImpl.unbindService   ContextImpl.java, line 1808
3   android.content.ContextWrapper.unbindService    ContextWrapper.java, line 551
4   com.example.BeaconUtils$BeaconConsumerImpl.unbindService    BeaconUtils.java, line 195
5   org.altbeacon.beacon.BeaconManager.unbind

I’m calling BeaconManager#bind and BeaconManager#unbind synchronously in a background thread. I wait for BeaconConsumer#onBeaconServiceConnect or a timeout, then I wait for MonitorNotifier#didDetermineStateForRegion or a timeout, I call BeaconManager#unbind. Occasionally, BeaconManager#unbind fails. Based on my review of your source. Two things could cause this:

BeaconManager#bind’s call to BeaconConsumer#bindService could fail. BeaconManager#bind doesn’t return this success boolean to the caller, nor does it handle this failure in any way internally. If we later call BeaconManager#unbind, the call will throw the IllegalArgumentException described above.

BeaconManager#beaconServiceConnection could receive an #onServiceDisconnected callback after BeaconManager#bind is called. Since BeaconManager#beaconServiceConnection is already unbound, when we later call BeaconManager#unbind, the call will throw the IllegalArgumentException described above.

Please make BeaconManager#bind return a success boolean, and add a onBeaconServiceDisconnect method to BeaconConsumer.

Thanks!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
vinceramcesoliveroscommented, Aug 2, 2018

just want to say Hi because I get an error to a different platform, although it is somewhat related. I’m using Flutter project, I created an issue to the guy created the package using altbeacons. then i get this error.

Edit: kinda fixed the issue now by commenting beaconClient.unbind().

0reactions
davidgyoungcommented, Aug 6, 2021

closed per #1046

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Context dispatchStatusEventAsync throwing ...
However, in watching the logs returning from LogCat while the AIR app is running, I'm seeing an IllegalArgumentException being thrown each time ...
Read more >
Java – How to get the AltBeacon library's BootstrapRegion to ...
I'm using the BeaconManager to ... BeaconManager; import org.altbeacon.beacon. ... to launch every single time beacons come into view, remove this call.
Read more >
com.squareup.otto.Bus.unregister java code examples - Tabnine
Creates a new Bus with the given identifier that enforces actions on the main thread. dispatch. Dispatches event to the handler in wrapper....
Read more >
[Solved]-Altbeacon not finding beacons on android 8+-kotlin
The reason this wasn't working is because I was binding the beacon before actually adding the Beacon layout... Before: beaconManager?.bind(view) ...
Read more >
Using autobind APIs - Android Beacon Library
Remove any catch blocks or throws declarations for RemoteException as the above replacement methods do not throw this exception. Remove any calls to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found