GroundSDK BLUETOOTH_CONNECT [MissingPermission]

Hi,

I’m trying to build GroundSDK on Ubuntu 20.04.3 in VirtualBox 6.1.28 on Win10 via the command from the documentation:

$ ./build.sh -p groundsdk-android -t build -j

I’m getting the bellow errors.
Any ideas how to solve the issues?

Task :groundsdkdemo:lint
Ran lint on variant debug: 14 issues found
Ran lint on variant release: 14 issues found
Wrote HTML report to file:///home/user1/devs/groundsdk/out/groundsdk-android/gradle/groundsdkdemo/reports/lint-results.html
Wrote XML report to file:///home/user1/devs/groundsdk/out/groundsdk-android/gradle/groundsdkdemo/reports/lint-results.xml

Task :groundsdkdemo:lint FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:groundsdkdemo:lint’.

Lint found errors in the project; aborting build.

Fix the issues identified by lint, or add the following to your build script to proceed with errors:

android {
lintOptions {
abortOnError false
}
}

The first 3 errors (out of 11) were:

/home/user1/devs/groundsdk/packages/groundsdk-android/sdkcore/src/main/java/com/parrot/drone/sdkcore/arsdk/backend/ble/ArsdkBleConnection.java:191: Error: Missing permissions required by BluetoothDevice.connectGatt: android.permission.BLUETOOTH_CONNECT [MissingPermission]
mGatt = mBtDevice.connectGatt(mContext, false, mDeviceConnectionListener);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/user1/devs/groundsdk/packages/groundsdk-android/sdkcore/src/main/java/com/parrot/drone/sdkcore/arsdk/backend/ble/ArsdkBleConnection.java:211: Error: Missing permissions required by BluetoothGatt.close: android.permission.BLUETOOTH_CONNECT [MissingPermission]
mGatt.close();
~~~~~~~~~~~~~
/home/user1/devs/groundsdk/packages/groundsdk-android/sdkcore/src/main/java/com/parrot/drone/sdkcore/arsdk/backend/ble/ArsdkBleConnection.java:239: Error: Missing permissions required by BluetoothGatt.writeDescriptor: android.permission.BLUETOOTH_CONNECT [MissingPermission]
mGatt.writeDescriptor(descriptor);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With regards,
4km

Hi,

I confirm I also get this error when building with recent sdk tools (hence a recent lint version).

I do not really understand why lint reports this as an error, because we are still targeting SDK 29, and the ‘missing’ permissions are only required when targeting SDK >= 31, as mentioned in android documentation: Bluetooth permissions  |  Android Developers.

On your side, you may do as suggested by lint, i.e. allowing the build to proceed with errors. To do so, edit file ‘products/groundsdk/android/gradle/build.gradle’; inside the android block line 104, add

lintOptions {
    abortOnError false
}

Another way to solve the issue is to suppress the warning from source:

  • edit file packages/groundsdk-android/sdkcore/src/main/java/com/parrot/drone/sdkcore/arsdk/backend/ble/ArsdkBleDiscovery.java and add @android.annotation.SuppressLint("MissingPermission") above line 70 (final class ArsdkBleDiscovery extends ArsdkDiscovery {)
  • edit file packages/groundsdk-android/sdkcore/src/main/java/com/parrot/drone/sdkcore/arsdk/backend/ble/ArsdkBleConnection.java and add @android.annotation.SuppressLint("MissingPermission") above line 62 (final class ArsdkBleConnection {)

This should allow you to proceed with the build.
I will also look at how we can fix this issue on our side.

Regards,
Mathieu

Hi,

thank you for the detailed hints.
I used the first one with the lintOptions.

With regards,
4km

This topic was automatically closed after 30 days. New replies are no longer allowed.