Maaz Zindani

Loading the index…

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

Gradle will not install an Android SDK package until you accept its licence

ErrorFailed to install the following Android SDK packages as some licences have not been accepted.

Short answer

Gradle tried to download an SDK package, but the licence for it is not recorded on this machine. Run sdkmanager --licenses with the same SDK folder the build uses, answer y to each prompt, and build again. Most failures come from running sdkmanager against a different SDK folder than the one Gradle reads.

  • Applies to Android Gradle Plugin 8.x and 9.x, Android SDK Command-Line Tools latest, JDK 17, Ubuntu 24.04, macOS 26
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out which SDK folder the build uses, then check that the licenses folder exists inside it. The error names the packages that are missing a licence.

    echo "ANDROID_HOME=$ANDROID_HOME"
    grep sdk.dir android/local.properties local.properties 2>/dev/null
    ls "$ANDROID_HOME/licenses" 2>/dev/null || echo "no licenses folder here"
  2. 2Match what you see, then jump to its fix

    1. 1A fresh machine, container or CI runner, and no licenses folder inside the SDK folderThe licences were never accepted on this machine or CI imageFix
    2. 2sdkmanager says everything is accepted, yet Gradle still failssdkmanager accepted the licences for a different SDK folderFix
    3. 3sdkmanager: command not found, or the file exists only under cmdline-tools/binsdkmanager is not installed, or sits in the wrong folderFix

What does the error look like?

  • Failed to install the following Android SDK packages as some licences have not been accepted.
  • To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  • Android SDK Build-Tools 36 Android SDK Platform 36 Failed to install the following SDK components

Cause 1 of 3

The licences were never accepted on this machine or CI image

1Check

Gradle may download packages it needs, but only after you accept the licence for each one. Android Studio records your answer when you install through its SDK Manager. A machine with only the command-line tools has no such record.

ls "$ANDROID_HOME/licenses"
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --list_installed

2Fix

Run sdkmanager --licenses and accept each licence. In a CI script, pipe y into it so it does not wait for a keyboard.

"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses
# non-interactive (CI)
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses

3Verify

A second run reports that all licences are accepted, and the build gets past package download.

"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses
./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

sdkmanager accepted the licences for a different SDK folder

1Check

A licence is stored in the licenses folder of one SDK. If you ran sdkmanager from another install (for example a Homebrew copy or an old one), it wrote its answer there. Compare the folder in sdk.dir or ANDROID_HOME with the folder sdkmanager uses.

which sdkmanager
grep sdk.dir local.properties

2Fix

Run sdkmanager with --sdk_root pointing at the folder the build reads.

sdkmanager --sdk_root="$ANDROID_HOME" --licenses

3Verify

The licenses folder inside the SDK the build uses now has files, and the build runs.

ls "$ANDROID_HOME/licenses"
./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

sdkmanager is not installed, or sits in the wrong folder

1Check

sdkmanager comes with the Android SDK Command-Line Tools package. It must live in cmdline-tools/<version>/bin, for example cmdline-tools/latest/bin. If the unzipped folder was put straight under cmdline-tools, the tool cannot find the SDK.

ls "$ANDROID_HOME/cmdline-tools"

2Fix

Move the contents of the unzipped cmdline-tools folder into a sub-folder named latest, inside a cmdline-tools folder in the SDK. Or install Command-line Tools from Android Studio, SDK Manager, SDK Tools tab.

mkdir -p "$ANDROID_HOME/cmdline-tools/latest"
mv cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/"

3Verify

sdkmanager runs and lists installed packages.

"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --list_installed

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Put sdkmanager --licenses in your CI image setup, so the licence step runs once at build time of the image, not on every job.
  • Pin the SDK folder in one place (ANDROID_HOME) and always call sdkmanager with --sdk_root.
  • Keep the licenses folder in a cached or baked image layer instead of downloading it on each run.

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

Gradle cannot find the Android SDK on this machine

FAILURE: Build failed with an exception. What went wrong: SDK location not found.

Gradle looks for the Android SDK in the sdk.dir line of android/local.properties and in the ANDROID_HOME environment variable, and found neither.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

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.