Open FranciscoPV94 opened 1 year ago
You need to uninstall the app completely from your device and reinstall it. Make sure, that you have granted all the permissions. This worked at my case (with the same error).
E/MethodChannel#flutter_bluetooth_serial/methods(15942): Failed to handle method call E/MethodChannel#flutter_bluetooth_serial/methods(15942): java.lang.SecurityException: Permission Denial: starting Intent { act=android.bluetooth.adapter.action.REQUEST_ENABLE cmp=com.oplus.wirelesssettings/com.android.settings.bluetooth.RequestPermissionActivity mCallingUid=10232 } from ProcessRecord{fdf8346 15942:com.example.bluetooth_app/u0a232} (pid=15942, uid=10232) requires android.permission.BLUETOOTH_CONNECT
Same issue, also not working on the release mode
Have you explicitly requested the permission from within the app? From that Android developer website link:
The BLUETOOTH_ADVERTISE, BLUETOOTH_CONNECT, and BLUETOOTH_SCAN permissions are runtime permissions. Therefore, you must explicitly request user approval in your app before you can look for Bluetooth devices, make a device discoverable to other devices, or communicate with already-paired Bluetooth devices. When your app requests at least one of these permissions, the system prompts the user to allow your app to access Nearby devices, as shown in figure 1.
To do this, use the permission_handler plugin.
Problem summary
Apparently the problem is due to the new version of Android 12, which needs bluetooth access permissions. I am testing on a moto g50 with android 12, I tried on a moto g70 with android 11 and everything works fine.
in android docs find this https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android12-or-higher
Steps to reproduce
I add java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT but it doesn't work
Environment
flutter --version Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision f4abaa0735 (1 year, 6 months ago) • 2021-07-01 12:46:11 -0700 Engine • revision 241c87ad80 Tools • Dart 2.13.4