Skip to content
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

I add java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT but it doesn't work #187

Open
FranciscoPV94 opened this issue Dec 20, 2022 · 4 comments

Comments

@FranciscoPV94
Copy link

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

  1. E/MethodChannel#flutter_bluetooth_serial/methods( 4896): Failed to handle method call
    E/MethodChannel#flutter_bluetooth_serial/methods( 4896): java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@8702d63b: getName

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

@Lauritz-Tieste
Copy link

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).

@akhilgorantala
Copy link

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

@MazenCoder
Copy link

Same issue, also not working on the release mode

@tomc128
Copy link

tomc128 commented Apr 21, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants