pythonandroidbluetoothkivypyjnius

Permission BLUETOOTH for Android 13 in kivy app


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


Solution

  • Add this code to your main.py program:

    from android.permissions import request_permissions, Permission 
    request_permissions([Permission.BLUETOOTH_CONNECT,Permission.BLUETOOTH_SCAN ])