Closed Mehdi-Mouilbeau closed 1 year ago
the logs seem pretty clear.
have you set permissions?
also it appears you are calling stopScan too quickly?
here's my AndroidManifest for permissions :
New Bluetooth permissions in Android 12 uses-permission android:name="android.permission.BLUETOOTH_SCAN"/> uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> legacy for Android 11 or lower --> uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> Needed only if your app makes the device discoverable to Bluetooth devices. uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
That's how the problem arose. I don't think I changed anything. I even went back to an older commit or another branch to test and the problem is still there. I thought it was an environment problem, so I tested on windows and apple, same problem. I haven't changed the way I call stopscan since it worked like that. I can try.
it says you need BLUETOOTH_PRIVILEGED
I've tried it with and without, and nothing has changed.
lmk if you figure it out
Hello, We were able to target the problem by removing the withServices parameter from the startscan. There seems to be an incompatibility with Android when trying to access the Guid (hence the bluetooth privileged permission). Fyi, result is the same with or wihtout this permission in the manifest. On the first scan it finds several Bluetooth devices, but on the next ones it finds none.
"Restricted Permission: The BLUETOOTH_PRIVILEGED permission is a protected-level permission. This means it's not available to all apps. Typically, only system apps or apps signed with the system's signing key can obtain this permission. Regular third-party apps cannot use this permission due to security reasons."
yes seems like you're doing something that is not allowed.
what service are you trying to scan for?
Same happened to me when I tried scanning with the withNames parameter. I ended up dropping it and revert to a manual .where filter
@cl-lumoshelmet which android version?
I'm running on a Huawei Mate 30 (EMUI 12), Android 10
Surely something happened on the Android side because overnight, it stopped working without having changed anything in my code. I solved the problem by removing the withServices from startScan.
For information, this is not a system application.
what service are you scanning for
Need BLUETOOTH_PRIVILEGED permission: Neither user 10502 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
According to this issue, your bluetooth is not enabled.
You can update to 1.27.6 or later. I added checks for bluetooth being off before we scan.
If this does not fix it, please reopen a issue.
Requirements
Have you checked this problem on the example app?
Yes
FlutterBluePlus Version
1.22.0
Flutter Version
3.13.8
What OS?
Android
OS Version
Android 10 /12 and 14
Bluetooth Module
Honor 9X / Tab Lenovo / Pixel 7
What is your problem?
Hello,
For a week now I can't detect my Bluetooth device. The detection was working fine and then nothing even after several attempts. I tried from another environment, same thing. It will find my device once and then nothing.
Logs
Logs for Android 9/10 :
Logs for Android 12 or higher :