APK errors

compileSdk is too low

Error text

Dependency 'androidx.core:core-ktx:1.13.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs.
:app is currently compiled against android-33.

Cause

A newer library was built against newer Android APIs. The app's compileSdk lags behind it.

Step-by-step fix

  1. Raise compileSdk to the number in the error or higher.
  2. Install that platform in SDK Manager: platforms;android-34.
  3. Raising compileSdk does not change app behavior; it only affects compiling.
  4. Raise targetSdk separately and carefully: read the behavior changes first.
  5. Rebuild with ./gradlew clean assembleDebug.

Example commands

android {
  compileSdk = 34
  defaultConfig { targetSdk = 34 }
}
sdkmanager "platforms;android-34" "build-tools;34.0.0"
./gradlew assembleDebug

How to prevent it

Update compileSdk every year when a new Android ships; libraries follow it.

Author and license: Nibras Code