-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scanForDevices fails on Android 12. #496
Comments
I am able to run the example app on my pixel4a with Android 12. Can you try to run our example app on your phone? Also we need some more logical output because the only thing what I can see is that the library correctly propagates a native error. |
This is probably because you did not request permission from the user. This is now required on Android 12: if (Platform.isAndroid) {
|
As soon as I can put again my hands on an Android 12 Phone, I will try to run the Example. |
Here, as I told, on Android 7 to 11 it works: `
} Future bleRequestPermissions(
|
Hi Giacomo, I had the same issue after Samsung released Android 12 to my S21. 1)Change uses-permission in android manifest ( removed android:maxSdkVersion="30"):
2) Change android\build.glade (kotlin_version = 1.5.31)
3) change android\app\build.grade (compileSdkVersion 31, minSdkVersion 21, targetSdkVersion 31)
4) Request the follow permissions
|
You have to add |
As now, I've solved with ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION. But I cannot understand why I need these permissions on Android 12, expecially while specifying "neverForLocation" on BLUETOOTH_SCAN.
|
I had the same issue with my Samsung Galaxy S10+ Android 12 Update. This resolves the issue for me. Thanks! |
Like mentioned in #498 the readme file explains what permission-setup you'd need when supporting Android X...12. Also see the manifest of the example app. README: https:/PhilipsHue/flutter_reactive_ble#which-permissions-are-needed |
Hello good people, I managed to get this working on Android 12.
So the gist is, use toos:node="remove" to remove any permission from the merged manifests so that we don't add any derivatives of the permissions that any of the dependencies might have. To add the tools:node features add this to the top of your manifest:
|
This is already documented in the readme: https:/PhilipsHue/flutter_reactive_ble#which-permissions-are-needed |
My App is running on almost 3000 Devices without any problem until Android 12 Release, on this OS version it is imposible to execute a scan.
Example: the app was working fine on a Samsung Galaxy S21 Ultra with Android 11, the user upgraded the OS as soon it was available from Samsung, and now, when executing:
_ble.scanForDevices( withServices: [sUuid], ).listen((device) { add(BleEventConnectDevice(deviceId: device.id)); }, onError: ((error) { add(BleEventError(state: state, error: 'Errore Connessione: ' + error.toString())); }));
OnError is called and error description is:
GenericFailure<ScanFailure>(code: ScanFailure.unknown, message: "Bluetooth cannot start (code 0)")
This is from the App's Merged Manifest :
'
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" / >
<uses-permission-sdk-23
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" / >
<uses-permission-sdk-23
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" / >
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" / >
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" / >'
Same problem on a Google Pixel 5, and other Samsung smartphones.
How can I solve this, before more users loose ability to use my app?
The text was updated successfully, but these errors were encountered: