[ANDROID] BLE VERSION Android 12

In Android version 12, BLE SCAN operation is a problem.

In case you want to solve this, I found the site address.

android:usesPermissionFlags="neverForLocation"

How do I add the above in ‘Processing’?

https://developer.android.com/guide/topics/connectivity/bluetooth/permissions

The following code snippet shows how to update your app’s manifest file:

<manifest>
    <!-- Include "neverForLocation" only if you can strongly assert that
         your app never derives physical location from Bluetooth scan results. -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />

    <!-- Not needed if you can strongly assert that your app never derives
         physical location from Bluetooth scan results and doesn't need location
         access for any other purpose. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    ...
</manifest>
1 Like

@svan

Thanks for the kind reply and explanation.
Have you ever proceeded with that?
I tried to go ahead and process it, but it didn’t work.
A debugging error has occurred.

I never got BLE to work. I saw the reference and thought it answered your question. What is the ‘debugging error’?

1 Like
    </application>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
    <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
    <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED"/>
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>

@svan

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:processDebugResources’.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\ANDROID\AppData\Local\Temp\android678394571626604992sketch\app\build\intermediates\packaged_manifests\debug\AndroidManifest.xml:22: AAPT: error: attribute android:usesPermissionFlags not found.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3s
20 actionable tasks: 20 executed

Dear svan / @svan

It doesn’t compile as above.
Adding android:usesPermissionFlags=“neverForLocation” gives an error.

Why?
Or is there any workaround?

@GWAK The permission that you are trying to include comes with Android 12 (API 31). Changing android:maxSdkVersion=“30” to android:maxSdkVersion=“31” in the manifest may resolve. Android Mode recently upgraded to use Android 30 and can shift to Android 31 in the near future.

Best,
Rupesh

1 Like