sdkmanager --licenses: Accept Android SDK Licenses in CI
sdkmanager --licenses prompts to accept every pending Android SDK license; piping yes accepts them all non-interactively for CI.
Gradle refuses to download SDK components until the licenses are accepted, and the prompt hangs a headless job. Accepting them up front is a one-liner that prevents the single most common Android CI failure.
What it does
sdkmanager --licenses walks through each SDK package license that has not been accepted and asks y/N. Accepting writes hashes into $ANDROID_HOME/licenses/. Gradle and the Android Gradle Plugin check that directory and fail the build if a required license is missing.
Common usage
yes | sdkmanager --licenses
# quieter variant
yes | sdkmanager --licenses > /dev/null
# accept into a specific SDK root
yes | sdkmanager --sdk_root=$ANDROID_HOME --licensesOptions
| Form | What it does |
|---|---|
| --licenses | Review and accept pending SDK licenses |
| yes | ... | Auto-answer y to every prompt |
| --sdk_root=<dir> | Accept licenses for a specific SDK directory |
| $ANDROID_HOME/licenses/ | Directory of accepted license hash files |
In CI
Run yes | sdkmanager --licenses before any Gradle Android build. Alternatively, commit the license hash files into $ANDROID_HOME/licenses (android-sdk-license, android-sdk-preview-license) so no network step is needed. The android-actions/setup-android action handles this for you.
Common errors in CI
"You have not accepted the license agreements of the following SDK components" (with a list of build-tools/platforms) from the Gradle build means the licenses directory is missing or incomplete; run the yes-pipe accept. A hang at the license prompt means you forgot the yes | pipe on a non-interactive runner. "Warning: File ... licenses: not writable" means the SDK root permissions block writing the accepted hashes.