How to Fix Android SDK License Not Accepted Error
In this tutorial, you'll learn about How to Fix Android SDK License Not Accepted Error. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
The Problem
You see Failed to install the following Android SDK packages as some licenses have not been accepted or the error You have not accepted the license agreements of the following SDK components. This commonly occurs in headless environments like CI servers (GitHub Actions, Jenkins, GitLab CI) or on a freshly installed Android SDK. Before you can use any platform or build tool, you must accept the licenses once per SDK installation.
Quick Fix
1. Accept all SDK licenses automatically
If you have sdkmanager installed, run:
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
Expected output:
5 of 5 SDK package licenses not accepted.
Review licenses... (y/N) All SDK package licenses accepted.
The yes command pipes "y" repeatedly, accepting every license prompt.
2. Install cmdline-tools if sdkmanager is missing
mkdir -p ~/android/cmdline-tools
cd ~/android/cmdline-tools
wget https://dl.google.com/android/repository/commandlinetools-linux-latest.zip
unzip -q commandlinetools-linux-latest.zip
mv cmdline-tools latest
Set environment variables:
export ANDROID_HOME=~/android
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
Add them to ~/.bashrc or ~/.zshrc for persistence:
echo 'export ANDROID_HOME=~/android' >> ~/.bashrc
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools' >> ~/.bashrc
Then accept licenses:
yes | sdkmanager --licenses
3. Accept licenses for specific packages only
yes | sdkmanager "platforms;android-34" "build-tools;34.0.0"
Expected output:
Loading package information...
Installing: platforms;android-34
Installing: build-tools;34.0.0
4. Set up for CI (GitHub Actions example)
In your workflow YAML:
- name: Accept Android SDK licenses
run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null 2>&1 || true
The > /dev/null 2>&1 || true suppresses output and ensures the step does not fail if licenses were already accepted.
5. Verify the acceptance
sdkmanager --list --include_installed | grep -E "Installed packages|platforms;android"
Expected output:
Installed packages:
Path | Version | Description
platforms;android-34 | 34 | Android SDK Platform 34
6. If the error persists, check Android_HOME is set correctly
echo $ANDROID_HOME
ls $ANDROID_HOME/
Expected output:
/home/user/android
cmdline-tools licenses platforms platform-tools
If Android_HOME is empty, set it in your shell profile:
echo 'export ANDROID_HOME=~/android' >> ~/.bashrc
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools' >> ~/.bashrc
source ~/.bashrc
7. Use the non-interactive license acceptance method
touch "$ANDROID_HOME/licenses/android-sdk-license"
echo -n "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/Android-sdk-license"
This manually writes the license hash so tools see it as accepted without running the interactive prompt.
Prevention
- Run
sdkmanager --licensesonce after every Android SDK tools update - Add
yes | sdkmanager --licensesas an early setup step in all CI configuration files - Set
ANDROID_HOMEpermanently in your shell profile to avoid path-related issues - Use
export ANDROID_SDK_ROOT=$ANDROID_HOMEfor older build tools that expect the legacy variable name - If using a Docker image, accept licenses during the image build phase rather than at container start
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro