Accept Android build tools licenses

Andres Sandoval
1 min readAug 6, 2023

When using the latest Gradle(alpha) versions we get the build error “Failed License not accepted for build tools”. The solution is to add command to accept the license. Below are code snippets to fix Github actions and Dockerfile.

Error:

Checking the license for package Android SDK Build-Tools 34-rc3 in /usr/local/lib/android/sdk/licenses

Warning: License for package Android SDK Build-Tools 34-rc3 not accepted.
FAILURE: Build failed with an exception.

How to fix error on Github Actions:

  steps:
- name: List Android Packages
run: sudo $ANDROID_HOME/tools/bin/sdkmanager --list | sed -n '/Available Packages/q;p'
- name: Accept license 34.0.0-rc3
run: echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "build-tools;34.0.0-rc3"

How to fix error on Dockerfile:

RUN echo yes | ${ANDROID_HOME}/cmdline-tools/tools/bin/sdkmanager "build-tools;34.0.0" && \
echo yes | ${ANDROID_HOME}/cmdline-tools/tools/bin/sdkmanager "platforms;android-33"

Solution to solve this error:

Conclusion

Thanks for spending your time reading it and let me know if I’m wrong somewhere or if there’s something that could do differently or better. I’m open to your feedback 🙌🏻

-Andres

Related article:

https://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences

--

--