Error “Scan failed, app cannot be registered” in s

2019-07-18 03:49发布

问题:

When ranging beacons on an android device, an error occurs after some time (about 3-5 minutes). After this, the ranging no longer sees the beacons. It helps only reboot the Bluetooth. After rebooting the ranging starts working normally, the beacons are detected, but after a while, the failure again occurs. As far as I understand, client connections overflow. I learned logcat and determined the following errors:

GATT_Register: can not Register GATT client, MAX client reached! CycledLeScannerForLollipop Scan failed:app cannot be registered BluetoothLeScanner onClientRegistered () - status = 133 clientIf = 0 mClientIf = 0

How much I understand status should be 0. I note once again that the feature of the work is a service that runs in a separate process from the application itself. Strings from logcat with the BluetoothLeScanner filter at the moment when the service stops seeing the beacons:

    Debug   12591   BluetoothLeScanner  onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=133 clientIf=0 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=32 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=32 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=31 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=30 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=29 mClientIf=0
Debug   12591   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=28 mClientIf=0

It is possible as that to solve the given problem? Thank you!

EDIT: This is logcat:

  Time           Device Name  Type     PID           Tag          Message
02-19 18:49:45.395  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=133 clientIf=0 mClientIf=0
02-19 18:49:40.375  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=32 mClientIf=0
02-19 18:49:35.333  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=31 mClientIf=0
02-19 18:49:30.411  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=30 mClientIf=0
02-19 18:49:25.256  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=29 mClientIf=0
02-19 18:49:20.234  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=28 mClientIf=0
02-19 18:49:15.185  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=27 mClientIf=0
02-19 18:49:10.181  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=5 mClientIf=0
02-19 18:49:05.170  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=26 mClientIf=0
02-19 18:49:00.124  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=26 mClientIf=0
02-19 18:48:55.108  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=25 mClientIf=0
02-19 18:48:50.078  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=25 mClientIf=0
02-19 18:48:45.028  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=23 mClientIf=0
02-19 18:48:39.992  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=24 mClientIf=0
02-19 18:48:39.316  AGM A8  Debug   3254    BluetoothLeScanner  onClientRegistered() - status=0 clientIf=23 mClientIf=0
02-19 18:48:34.994  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=22 mClientIf=0
02-19 18:48:29.927  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=21 mClientIf=0
02-19 18:48:24.905  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=20 mClientIf=0
02-19 18:48:19.866  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=19 mClientIf=0
02-19 18:48:14.852  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=18 mClientIf=0
02-19 18:48:09.825  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=17 mClientIf=0
02-19 18:48:04.812  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=16 mClientIf=0
02-19 18:47:59.768  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=15 mClientIf=0
02-19 18:47:54.751  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=14 mClientIf=0
02-19 18:47:49.708  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=13 mClientIf=0
02-19 18:47:44.688  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=12 mClientIf=0
02-19 18:47:39.676  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=11 mClientIf=0
02-19 18:47:34.662  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=10 mClientIf=0
02-19 18:47:29.603  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=9 mClientIf=0
02-19 18:47:24.585  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=8 mClientIf=0
02-19 18:47:19.552  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=7 mClientIf=0
02-19 18:47:14.525  AGM A8  Debug   13351   BluetoothLeScanner  onClientRegistered() - status=0 clientIf=7 mClientIf=0

回答1:

On some Android device models, the Bluetooth stack can get into a bad state requiring a power cycle to make it able to scan for bluetooth devices again. In order to automate a fix for this problem, a BluetoothMedic has been added to the Android Beacon Library which will automatically power cycle bluetooth when a problem is detected. As of this writing, this change is still in a pull request so not yet merged into a release build of the library.

While this is a workaround for your problem, the core issue is probably that you have too many Bluetooth scanning apps installed on your phone. Android limits the number of apps simultaneously using a Bluetooth client to 32. If you have more than that many apps installed that are trying to use Bluetooth LE APIs, you will get this error, and only a power cycle of bluetooth (which may be automated by the BluetoothMedic above) can recover from the problem. This will effectively kill the use of the bluetooth APIs on the other apps so your app has a chance to use them.



回答2:

Simply turn off the Bluetooth of your phone and run a system clean then run the app again. This solved my problem and headache also.