A Comprehensive Guide to Migrating Your Android App to Android 14 (API Level 34)

Ritesh Gupta
3 min readMar 6, 2024

--

Hello readers, In this article I am going to show you how you can migrate your Android app to Android 14 (API level 34) without much hustle. So, just stick with the article. Let’s start…

First, Let's change the complieSdk and targetSdk to 34 and go to File -> Sync project to Gradle file.

Ok coool…

Now, Let’s see the list of behavior changes that may affect your app running on Android 14 or later.

Behavior changes in Android 14 or higher:

Foreground service types are mandatory

If you are using any foreground service in your project. Then it is mandatory to specify the android:foregroundServiceType in the Service declaration in AndroidManifest.xml

Available foregroundServiceType are camera, connectedDevice, dataSync, health, location, mediaPlayback, mediaProjection, microphone, phoneCall, remoteMessaging, shortService, specialUse, systemExempted

You can learn more about foregroundServiceType here.

BLUETOOTH_CONNECT permission in AndroidManifest.xml

If you are using Bluetooth service in your project. Then you have to add BLUETOOTH_CONNECT permission in AndroidManifest.xml

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

JobScheduler reinforces callback and network behavior

If your app targets Android 14 (API level 34) or higher and exceeds the granted time of onStartJob and onStopJob on the main thread, the app triggers an ANR.

If you are using setRequiredNetworkType or setRequiredNetwork constraint in JobScheduler. Then it is mandatory to mention ACCESS_NETWORK_STATE permission in AndroidManifest.xml else it will throw SecurityException

Migrate to WorkManager, which provides asynchronous processing.

Secure full-screen Intent notifications

We were using Notification.Builder.setFullScreenIntent to send full-screen intents (from Android 11, API level 30) while the phone is locked. You could auto-grant this on app install by declaring USE_FULL_SCREEN_INTENT permission in the AndroidManifest.xml but now the user can turn off this permission from app settings.

You can use NotificationManager.canUseFullScreenIntent to check if your app has permission to show full-screen intent. If not, you can use the new intent ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT to launch the settings page where users can grant permission.

Restrictions to implicit and pending intents

From Android 14, you have to make the intent explicit by giving the packageName of the destination else It will throw an exception when targeting Android 14.

val explicitIntent = Intent("com.example.action.APP_ACTION")
explicitIntent.apply {
package = context.packageName
}
context.startActivity(explicitIntent)

Runtime-registered broadcast receivers must specify export behavior

If you are using context-registered receivers then you have to specify a flag to indicate whether or not the receiver should be exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED.

That’s it for the migration guide & crucial changes of Android 14.

Happy Coding!

--

--