Build Fails on Acceptance of License Agreements

Today new builds seem to be failing on acceptance of License Agreements.

Warning: License for package Android SDK Build-Tools 26.0.3 not accepted.
Checking the license for package Android SDK Platform 26 in /opt/android/sdk/licenses
Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 26.0.3, Android SDK Platform 26].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

Can anyone shed some light on this.

Thanks

1 Like

Having the same issue. This is using the api-27-alpha docker image for reference.

According to the URL the message provides, it appears that we need to add a license folder to where the Android SDK manager lives on the build machine in order to allow the SDK manager to download the appropriate libraries.

Ref: https://developer.android.com/studio/intro/update#download-with-gradle

Perhaps this is missing from the docker image?

The licenses for the SDK components recently got updated, and the old yes | sdkmanager --licenses workaround doesn’t pick up the new licenses.

Adding this to my CircleCI config (before installing the SDK components) solved it for me - just check that the path matches your android-sdk path:

      - run:
          name: Copy SDK License
          command: printf "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee\n" > ~/android-sdk-linux/licenses/android-sdk-license

You can get those license ids by:

  1. Start with a fresh android-sdk install (or do an SSH rebuild on CircleCI).
  2. Install the relevant sdk components, e.g. with sdkmanager "build-tools;26.0.3", and manually accept the license.
  3. Check the contents of $ANDROID_HOME/licenses/android-sdk-license.

I also had this problem I fixed by getting the licenses from my local development machine in $HOME/Library/Android/sdk/licenses on OSX. I added them to git and copy them in my build for now.

config.yml

      - run:
          name: Install licenses
          command: cp licenses/* /opt/android/sdk/licenses/

Hello,

Please remove the -alpha tags from your images.

You may need to update your image to one of the currently available tags here: https://hub.docker.com/r/circleci/android/tags

Thanks @KyleTryon. I didn’t realize we have non alpha versions available. Is alpha meant to be a “canary” build or they legacy when moving over to docker images?

Also for future reference, I added a new step & command to my circle.yml file which approves all Android SDK licenses:

yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses || if [ $? -ne '141' ]; then exit $?; fi;  #Captures SIGPIPE 141 error but still allow repeating "y" to accept all licenses

Since CircleCi captures pipe errors, that if statements captures the 141 error that occurs. All other errors are reported. error 141 occurs when sending input to a command that no longer exists.

This works on the same docker image as before. No additional changes were necessary.

3 Likes

@jasenmoloy This is really clever.
I figured that it’s a false fail, since it clearly states that:

All SDK package licenses accepted.

And then exits with the non-0 141 code.

Thanks for this, my first green build on CircleCI is because of you!

Cheers,

Tom

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.