I have an error with bluetooth on android 12, Xiaomi Poco X3 NFC

The error that I'm getting is "lacks permission android.permission.BLUETOOTH ",I already gave all possible permissions and it still doesn't work. Can anyone help?

I understand that you are using the built-in Bluetooth client component?

yes

I'm already checking how AppInventor deals with bluetooth permissions for different versions of android.

Thank you :grin:

From what I can see, BLUETOOTH and BLUETOOTH_ADMIN permissions are always requested regardless of the android version, which is a mistake.

According to google, the BLUETOOTH and BLUETOOTH_ADMIN permissions apply to Android 11 version at most and these permissions should not be in Android 12.

<manifest>
    <!-- Request legacy Bluetooth permissions on older devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH"
                     android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
                     android:maxSdkVersion="30" />

    <!-- Needed only if your app looks for Bluetooth devices.
         If your app doesn't use Bluetooth scan results to derive physical
         location information, you can strongly assert that your app
         doesn't derive physical location. -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

    <!-- Needed only if your app makes the device discoverable to Bluetooth
         devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

    <!-- Needed only if your app communicates with already-paired Bluetooth
         devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

    <!-- Needed only if your app uses Bluetooth scan results to derive physical location. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    ...
</manifest>

And how do I change the manifest to remove those permissions?

You can edit the app using APK Editor Studio. After testing let me know if it worked.

Manifest from AppInventor:

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="31" android:compileSdkVersionCodename="12" package="appinventor.ai_froniu84a.height_keyboard" platformBuildVersionCode="31" platformBuildVersionName="12">
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
    <application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="height_keyboard" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
        <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:exported="true" android:name=".Screen1" android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <provider android:authorities="appinventor.ai_froniu84a.height_keyboard.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
        </provider>
    </application>
</manifest>

Instead of removing the permissions, add the missing MAX SDK to make your app work on older versions of Android as well.

If you don't know how, you can put your apk on google drive and put the link here, I'll edit it for you.

The problem is that this app is not the final app and It's a personal project so I'm the only one that will use it. I just have 1 question, that is, do I need to remove every permission or is it just the bluetooth related? I'm sorry for the bad english if you don't understand somethinh just tell me.

Try removing only those permissions. All together with <>

It gave me the same error, here it is the manifest file

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="31" android:compileSdkVersionCodename="12" package="appinventor.ai_agtenda.BracoRobo" platformBuildVersionCode="31" platformBuildVersionName="12">
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
    <application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="BracoRobo" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
        <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:exported="true" android:name=".Screen1" android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:configChanges="keyboardHidden|orientation" android:exported="true" android:name="com.google.appinventor.components.runtime.ListPickerActivity" android:screenOrientation="behind"/>
        <provider android:authorities="appinventor.ai_agtenda.BracoRobo.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
        </provider>
    </application>
</manifest>

Have you removed permission requests from your aia, from blocks?

I'm sorry to say this but I don't know how to make that

Put your aia project here. Maybe we started the whole diagnostics wrong.

here it is
BracoRobo.aia (1.7 KB)

I found it:

This seems to be a problem with xiaomi.

Try it:
BracoRobo.aia (1.8 KB)

No manifest change.

I added a block:

It worked, thank you

So xiaomi even though it has android12 still requires old permissions. From what I've read, the BLUETOOTH and BLUETOOTH_ADMIN permissions should not cause problems in android12, only google can get stuck after sending such an app to google play.