Need Help In Bluetooth Permission for an app on Android 12

I need a help in the app which I had created using MIT app inventor. If I am using this app in my phone which has Android 12 its not working and showing that "lacks permission (amdroid.permission.BLUETOOTH)
But when I use the app in the phone which has Android 10, the app works really well without any problem.

Welcome!
Interesting error message now after the new release...
are you using Bluetooth classic or BLE?
does this happen in the companion app or after building the app?
you already downloaded the latest version of the companion app?

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Hello Taifun,
I am developing the app for our College project and the poject is about, giving voice commands to Arduino using HC-05 bluetooth module, the ap I built is working fine with Android 10, but there's something wrong with Android 12 Bluetooth Permission.
I am not facing any problem in the app building, but the issue is with the apk.


Here's the blocks screenshot which you asked for. Please help me with this.

Thank You,
Mohit

Google has tightened security from Android 12+. Therefore, unfortunately, your App needs to find out what Android version it is on and handle permissions accordingly.

Looking at your code Blocks - are you sure that it working on Android 10? Using Activity Starter to ensure Bluetooth is enabled is fine, but App Inventor provides Blocks for permission requests, you do not need Activity Starter for that.

You have not stated what Bluetooth version you are using. There are two types of Bluetooth, "Classic" and "BLE" - they about the same as chalk and cheese.

See my website for a table that lists the Bluetooth versions and related type:

https://www.professorcad.co.uk/appinventortips#TipsBluetooth

You can use Anke's extension to get the API Level (relates to the Android Version, see my website) of the phone:

If using BLE, you need to ensure you have the most recent MIT BLE Extension version 20201223. You would also need to request some permissions, like this:

If you wish to ensure the User is asked to set Location on (BLE), drag a location sensor component into your project and additionally ask for permission ACCESS_FINE_LOCATION.

Tengo el mismo problema y no he conseguido solucionarlo

Buenas tardes

Tenía una app que se conectaba a un bluetooth con Arduino, hasta el viernes todo fue bien y funcionaba correctamente , pero hoy estaba haciendo unos tests 6 cua do complicaba la app después de seleccionar el bluetooth recibía :
Screenshot_2023-02-19-13-17-43-568-edit_com.miui.home

Para desechar otros problemas he hecho una aplicación muy simple de bluetooth y cuando la he instalado en el móvil


me ha dado el mismo error

Muchas gracias por su ayuda de antemano

Hello Sergio

Can you upload your test Project please (.aia)

I am having the same error message on Android 12. Error message shows either I build it or simulate using AI Companion. When I try to connect to an already paired device the error message shows up.
I have used Bluetooth Classic(Not BLE). I did not receive the error message before February 17th using these same blocks. Facing this issue after the release.
I don't have Android 10 or 11. No idea if it does work on those android versions.
bluetoothIssue

Hello Akash. I have asked the MIT team for advice. In the mean time, try this:

  1. Save a backup of your Project;
  2. Remove the permission requests;
  3. Test.

I am also facing the same kind of problem
the app that I did yesterday is working but it had few features so I decided to change the app with much more features by creating new project but getting this kind of error
I have use similar blocks to connect to Bluetooth but facing this issue

Tried with no success. Waiting for a solution from the MIT team.

Thanks for testing Akash.

Same here

Really new problem for me also .
running Android12 with BLUETOOTH_SCAN askForPermission when permissionName= BLUETOOTH_CONNECT.
. Changed recently after a new apk build on AI.

Evan Patton (MIT Guru) is looking into this issue.

Some guidance from Evan, but note this is not the official solution, a sample file is needed from one of you guys for studying at MIT:

Bluetooth Classic only (the Blocks that are integrated within App Inventor, not an extension (BLE))

Android 11 and below
BLUETOOTH and BLUETOOTH_ADMIN permissions.

Android 12+
BLUETOOTH_SCAN + BLUETOOTH_CONNECT permissions for clients and BLUETOOTH_ADVERTISE permission for the server component.

may be some indication for you here ?

Bluetooth permissions

I think the main thing we need to understand is what are people in this thread doing differently from a standard flow. We are following the Bluetooth permission guidelines published by Google, as linked above by @_Airsig3d. Specifically, in Android 12 and later Bluetooth permissions are moved to a runtime model where the app asks for permission from the user. App Inventor will automatically perform request the permission when certain methods in the BluetoothClient/BluetoothServer components are called (AcceptConnection, Connect, etc.).

BLUETOOTH_ADVERTISE is for Apps that are setup to be the Server. Usually, the device (e.g. microcontroller such as Arduino) is the Server and the App is the Client.

We really need to see your Project file to understand more about the issue

Project (.aia) to PC
Export Project

Upload to Forum Post
UploadToTopic

Hello All,
I am trying to search of BT devices and connect BT device from the list. But getting error 908 BLUETOOT_CONNECT permission.

Android version: 12
Using Bluetooth LE

Please go through the code blocks and help.

Here is a simple example (extract of one bigger program) to demonstrate the problem
When you will try to connect to a BT device , you shoudl have the problem .
Once again this is very new and was not there a few days ago.

TestBTConnect.aia (425.6 KB)