Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

A library needs a higher compileSdk than your module sets

ErrorDependency 'androidx.core:core:1.x.x' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs.

Short answer

A dependency declares a minimum compileSdk, and your module compiles against a lower one. The build fails at checkAarMetadata. Raise compileSdk in the module that fails to the number in the message. If the Android Gradle plugin does not support that level, update the plugin before you raise it.

  • Applies to Android Gradle Plugin 8.x and 9.x, Gradle 8.x and 9.x, JDK 17, Android Studio current stable
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the whole message. It names the dependency, the level it needs and the level your module uses. Then see where compileSdk is set.

    ./gradlew :app:checkDebugAarMetadata
    grep -rn "compileSdk" --include=*.gradle --include=*.kts .
  2. 2Match what you see, then jump to its fix

    1. 1:app is currently compiled against android-33 (or lower than the number in the message)compileSdk is lower than the library's minimumFix
    2. 2After you raise compileSdk, the build warns that the plugin was not tested with that levelThe Android Gradle plugin is too old for that API levelFix
    3. 3You do not use the named library directly, and it appeared after a version bump of another dependencyA transitive dependency pulled in a newer libraryFix

What does the error look like?

  • Dependency 'androidx.core:core:1.x.x' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs.
  • Execution failed for task ':app:checkDebugAarMetadata'.
  • :app is currently compiled against android-33.

Cause 1 of 3

compileSdk is lower than the library's minimum

1Check

A library can publish a minimum compileSdk in its AAR metadata. Consumers must meet it, otherwise Gradle reports it up front instead of failing later with a resource-not-found error.

grep -rn "compileSdk" --include=*.gradle --include=*.kts .

2Fix

Set compileSdk to the level the message asks for, or higher, in the module that fails. Install the matching platform in SDK Manager if it is missing.

// app/build.gradle.kts
android {
    compileSdk = 36
}
# install the platform
sdkmanager --install "platforms;android-36"

3Verify

Run the check again.

./gradlew :app:checkDebugAarMetadata

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

The Android Gradle plugin is too old for that API level

1Check

Each AGP release states the highest API level it supports. AGP 9.5, for example, supports up to API level 37, and needs Gradle 9.6.0 and JDK 17.

grep -rn "com.android.application\|agp" gradle/libs.versions.toml build.gradle* 2>/dev/null
cat gradle/wrapper/gradle-wrapper.properties

2Fix

Raise the AGP version, and the Gradle wrapper to the minimum that AGP needs, then raise compileSdk.

# gradle/libs.versions.toml
agp = "9.5.1"
# then sync; set the wrapper to the Gradle version AGP lists as its minimum

3Verify

Sync, and the checkAarMetadata task passes.

./gradlew :app:checkDebugAarMetadata

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

A transitive dependency pulled in a newer library

1Check

List the dependency tree and find which library brings the named one in.

./gradlew :app:dependencies --configuration debugRuntimeClasspath | grep -n "androidx.core"

2Fix

Preferably raise compileSdk. Or pin the older version of the dependency in your version catalog, until you can upgrade.

# gradle/libs.versions.toml
[versions]
androidx-core = "1.12.0"

3Verify

The dependency tree shows the older version and the check passes.

./gradlew :app:checkDebugAarMetadata

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Update compileSdk each year with the new Android release, and update AGP in the same change.
  • Upgrade AndroidX libraries in small steps and run a build after each bump.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.