Android "Failed to install SDK packages (licenses not accepted)" in CI
Gradle wants to install SDK packages but cannot because the corresponding license agreements have not been accepted on the runner.
What this error means
The build fails with Failed to install the following Android SDK packages as some licences have not been accepted, listing the packages. CI never accepted the licenses.
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-34 Android SDK Platform 34
build-tools;34.0.0 Android SDK Build-Tools 34Common causes
Licenses not accepted on a fresh runner
License acceptance is stored on disk; a clean runner has none accepted.
Missing license-accept step before the build
The job tried to build before running sdkmanager --licenses.
How to fix it
Accept licenses with sdkmanager
- Run sdkmanager --licenses and accept them non-interactively before building.
yes | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --licenses
./gradlew assembleDebugUse a setup action that accepts licenses
An Android setup action can install the SDK and accept licenses in one step, keeping the job declarative.
How to prevent it
- Accept licenses in a setup step or use a preinstalled SDK image. The download of SDK packages and the license metadata fetch are network calls. On Latchkey managed runners, self-healing auto-retries these transient downloads so a flaky fetch does not fail the job.