Need Help In Bluetooth Permission for an app on Android 12

I am not really sure what I can do, except buying a new phone :frowning:
But the real question is what is @Sudarshan_Gupta able to do.

And again, he should use the current BLE version.

Hi Mohit, I was able to solve the problem of Bluetooth Permission error.

  1. Build the APK file from your project in MIT APP inventor.
  2. Open the AndroidManifest.xml file to modify the permissions.
  3. Delete all permissions related to BLUETOOTH and add 3 lines.

  1. Save the AndroidManifest.xml file with above changes.
  2. Rebuild the APK file.

NOTE:

  1. How to view the AndroidManifest.xml?
    ------ Download APK Studio Editor from the link Download APK Editor for PC and Mac – APK Editor Studio
    ------ Open APK Studio Editor and Open the APK file.
    ------ Click on the "Open Contents" tab
    ------ Folder will be opened and "AndroidManifest.xml" file can be seen.

  2. How to Edit AndroidManifest.xml file?
    ------ Open the AndroidManifest.xml using any of the text editor.
    ------ Delete the lines related to Bluetooth related permissions.
    ------ Paste the below lines and save the changes.

  1. How to Rebuild the APK
    ------ After following the Step1 and Step2, On APK Studio Editor, Click on "SAVE APK"

Now, install the APK on mobile and Check the Bluetooth Permission Error Should be gone

3 Likes

Hi Madhav

I confirm that it s works for me . I changed the androidmanifest.xml , exactly as you perfectly explained us, with APK studio Editor .
I delete all line with mentionned bluetooth permission and changed at the beginning with your :

even if it is not necessary very pratical so far, many thanks to you

which means, you will not be able to upload your project to Google Play
Taifun

1 Like

Hi Taifun,

Thanks for letting know about this. I'm aware you have built your own extension for Bluetooth client. I believe you have enough info and means to solve the issue. Can you please help us.

that is true Anke.
I just tried the same but with targetSdkVersion="31" instead, and the bug is there again with the pop up : "need android.permission.BLUETOOTH_CONNECT .... "

But if we set to 31, then app throws an error for Bluetooth permission. How do we solve the issue then?

Also you can no longer upload / release an APK to the Play Store as long as the app (as APK) has not already been released before August 1st, 2021.

Will not help too much but targetSdkVersion="30" works also

In my bluetooth client extension I introduced a method to ask for permissions like this
in my tests this was working up to now...
Unbenannt2

Taifun

  /**
   * RequestBluetoothPermission
   */
  @SimpleFunction(description = "Request Bluetooth Permission.")
  public void RequestBluetoothPermission() {
    Log.d(LOG_TAG, "RequestBluetoothPermission");


    if (isRepl)
    {
      ErrorOccurred("You will have to build the app to be able to test this method.");
    } else if (ApiLevel()>30){
      ActivityCompat.requestPermissions(form,
          new String[] {
              "android.permission.BLUETOOTH_CONNECT",
              "android.permission.BLUETOOTH_SCAN",
              "android.permission.BLUETOOTH_ADVERTISE",
              "android.permission.ACCESS_FINE_LOCATION"
          }, BLUETOOTH_PERMISSION_REQUEST_CODE
      );
    } else {
      ActivityCompat.requestPermissions(form,
          new String[] {
              "android.permission.ACCESS_FINE_LOCATION"
          }, BLUETOOTH_PERMISSION_REQUEST_CODE
      );
    }
  }

thanks it help me, i just need to send data to hc-05 bluetooth don't need to post in google play store and it work

Thanks Taifun for the inputs.
But I feel the MIT should have the solution inbuilt for this issue.

BTReadWrite_2.aia (300.3 KB)

Summary

But, isn't this for the BLE and not for Classic Bluetooth??

Hc-05 is classic BT indeed. But both BT versions could use some more attention.

1 Like

I was referring to this app:

Apparently I've slowly lost track of what this is all about. No wonder after more than 120 posts. :upside_down_face:

Try this one (on Android 12+) → Companion & APK:
BluetoothClient_perm.aia (9.8 KB)

Blocks

And post screenshots after running Companion & APK.

Companion gets disconnected on its own after few seconds.
Screenshots of apk on phone as below,