Permission BLUETOOTH for Android 13 in kivy app

Question:

I am a beginner Kivy user. I made an app that displays Arduino data on mobile via Bluetooth. I allow access in buildozer.spec as follows:

android.permissions = BLUETOOTH_ADMIN,BLUETOOTH

The app worked well ,but now it can’t run on my android. I get an error like below:

JVM exception occurred : Need android.permission BLUETOOTH CONNECT permission for AttributionSource ( uid - 10316 packageName org test.myapp , attribution Tag- null , token android.os.BinderProxy@df550d7 , next null ) : Adapter Service getBondedDevices java.lang.securityException

How do I fix this error?

My app works fine on Android 11 and below but it doesn’t work on my mobile which its Android is 13.
Thank you in advance for your help

Asked By: Fathi

||

Answers:

In android 12 above You need to ask from the user
BLUETOOTH_SCAN and BLUETOOTH_CONNECT permission both.
under android 12 you need to ask ACCESS_FINE_LOCATION permission

Answered By: itzhak levy

Add this code to your main.py program:

from android.permissions import request_permissions, Permission 
request_permissions([Permission.BLUETOOTH_CONNECT,Permission.BLUETOOTH_SCAN ])
Answered By: tahami