Update the Android APP which uses nordic DFU
New target API requirement from Google
https://developer.android.com/google/play/requirements/target-sdk
1 | android { |
android:exported
https://developer.android.com/about/versions/12/behavior-changes-12
For Android 12 or higher, set “android:exported” attribute to “true” in the launch activity.
1 | <activity android:name=".activity.SplashActivity" android:exported="true"> |
New bluetooth permissions from Google
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions
For Android 12 lower, ACCESS_FINE_LOCATION & ACCESS_COARSE_LOCATION is required.
1 | <manifest> |
For Android 12 or higher, add the new permissions below.
1 | <manifest> |
Request for the BLE related permissions
https://developer.android.com/training/permissions/requesting
1 | if (Build.VERSION.SDK_INT < 31) { |
Update DFU lib to the latest version
DFU lib to the latest version
Was using the 1.11.0 and crashed when running on Android 12 phone.
Solution: Update the Nordic DFU lib to the latest version (current 2.3.0)
https://github.com/NordicSemiconductor/Android-DFU-Library1
2
3
4
5dependencies {
implementation 'no.nordicsemi.android:dfu:2.3.0'
...
}Kotlin version to 1.7.20
Was using the ext.kotlin_version = “1.4.32” and got build error after updating the DFU lib to 2.3.0.
Solution:1
2
3
4buildscript {
ext.kotlin_version = "1.7.20"
...
}Add foreground service permission to the project’s AndroidManifest.xml
Android foreground service:
https://developer.android.com/guide/components/foreground-services1
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>