New target API requirement from Google

https://developer.android.com/google/play/requirements/target-sdk

1
2
3
4
5
android {
compileSdkVersion 33
buildToolsVersion "33.0.2"
...
}

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
2
3
4
5
6
<manifest>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

...
</manifest>

For Android 12 or higher, add the new permissions below.

1
2
3
4
5
6
7
8
9
10
11
12
<manifest>
<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_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

...
</manifest>

Request for the BLE related permissions
https://developer.android.com/training/permissions/requesting

1
2
3
4
5
6
7
8
9
10
if (Build.VERSION.SDK_INT < 31) {
requestPermissions(arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION),
2)
}else{
requestPermissions(arrayOf(Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_ADVERTISE),
2)
}

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-Library

    1
    2
    3
    4
    5
    dependencies {

    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
    4
    buildscript {
    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-services

    1
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>