'androidx.emoji2:emoji2:1.4.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android API – Android

by
Alexei Petrov
android android-jetpack-compose gradle-kotlin-dsl

Quick Fix: Update compileSdk and targetSdk to version 34 or later in the build.gradle file. This will allow the app to compile against the latest Android APIs and resolve the compatibility issue with androidx.emoji2:emoji2:1.4.0.

The Problem:

An application’s dependency ‘androidx.emoji2:emoji2:1.4.0’ requires its dependent libraries and applications to compile against version 34 or later of the Android APIs. However, the current project is compiled against version 33. To resolve this issue, you should update the project’s compileSdk to at least version 34.

The Solutions:

Solution 1: Update `compileSdk` to 34

In the `app` module’s `build.gradle` file, update the value of `compileSdk` to 34. This will allow your app to use the Android APIs that are required by the `androidx.emoji2:emoji2:1.4.0` library.

android {
    compileSdk 34
    ...
}

This will fix the dependency conflict and allow your project to build successfully.

Note that updating the `compileSdk` does not change the app’s behavior. The app’s behavior will only change if you also update the `targetSdk`. You can update the `targetSdk` later, when you are ready to support the new features that are available in Android 34.

Solution 2: Downgrade the version of the dependent Compose Material library

You are using version 1.2.0 of the `androidx.wear.compose:compose-material` library, which requires Android API level 34 or higher. Since your project is compiled against API level 33, you need to downgrade the version of this library to one that is compatible with API level 33. For this case, version 1.1.2 should be used. Replace the following line in your `dependencies` block:

implementation("androidx.wear.compose:compose-material:1.2.0")

with:

implementation("androidx.wear.compose:compose-material:1.1.2")

This will downgrade the Compose Material library to a version that is compatible with API level 33 and should resolve the dependency conflict you are experiencing.

Q&A

How to fix the error caused by the androidx.emoji2:emoji2:1.4.0 library?

Change the project’s compileSdk to 34 or later.

Why can’t I use androidx.wear.compose:compose-material:1.2.0 with API 33?

The library is compatible with API 34 and above. Use version 1.1.2 for API 33.