Gradle will not install an Android SDK package until you accept its licence
Failed 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.
Fix it fast
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"2Match what you see, then jump to its fix
- 1
A 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
sdkmanager says everything is accepted, yet Gradle still failssdkmanager accepted the licences for a different SDK folderFix - 3
sdkmanager: command not found, or the file exists only under cmdline-tools/binsdkmanager is not installed, or sits in the wrong folderFix
- 1
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_installed2Fix
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" --licenses3Verify
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 assembleDebugConfirmed by developer.android.com
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.properties2Fix
Run sdkmanager with --sdk_root pointing at the folder the build reads.
sdkmanager --sdk_root="$ANDROID_HOME" --licenses3Verify
The licenses folder inside the SDK the build uses now has files, and the build runs.
ls "$ANDROID_HOME/licenses"
./gradlew assembleDebugConfirmed by developer.android.com
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_installedConfirmed by developer.android.com
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 fixMobile apps
flutter doctor says the Android cmdline-tools component is missing
Android license status unknown.
Flutter checks for a cmdline-tools folder inside the Android SDK it found, and stops the Android checks when that folder is absent.
6 causes, each with a fixMobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile 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