Android sdk license issue

Hi guys, i’ve faced this issue with build
What went wrong:

A problem occurred configuring project ‘:app’.

You have not accepted the license agreements of the following SDK components:

[Solver for ConstraintLayout 1.0.0-beta4, ConstraintLayout for Android 1.0.0-beta4].

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 Exporting licenses - Android Studio Project Site

  • Try:

Run with --info or --debug option to get more log output.

I think it’s issue on virtual machines

1 Like

Hi,

Thanks for asking this question here!

The official solution: You can find more info at the link printed in the log (http://d.android.com/r/studio-ui/export-licenses.html), but in short this can be done by:

Locate the licenses on your Mac/PC:

If you have accepted the license agreements on one workstation, but wish to build your projects on a different one,
you can export your licenses by copying the accepted licenses folder from the Android Sdk Home
folder (this should be located at <android sdk home path>/licenses) of your current workstation,
to the Android Sdk Home directory of the machine where you now want to build your projects.

  1. Create an android-licenses directory in the root directory of your git repository, and copy the license files into this directory from your Mac/PC.
  2. Then in your Workflow on bitrise.io copy the licenses to the right location using a Script step.

Add the Script step right after the Git Clone step (that’s when your code is available on the build virtual machine), with the content:

#!/bin/bash
# fail if any commands fails
set -e
# debug log
set -x

mkdir -p "$ANDROID_HOME/licenses"
rsync -avhP ./android-licenses/ "$ANDROID_HOME/licenses/"

That’s all, this script copies the licenses from the android-licenses (from your repository) into the system’s Android SDK Home path under licenses directory.

You can find more information and alternative solutions here: http://devcenter.bitrise.io/android/frequent-android-issues/#could-not-find-an-android-package-or-you-have-not-accepted-the-license-agreements , but the solution above is the current official solution (the “learn how to transfer the license agreements from one workstation to another” message in the log is not a Bitrise error/log, it comes from gradle and the Android tools).

Alternatively, if you don’t want to store the licenses in your repository (although that’s probably the best solution), you can also:

  • Using a ZIP file (Don’t use this method unless necessary, it’s way more complicated to get right than it seems!):
    1. ZIP the licenses and upload to Bitrise.io (using the Generic File Storage feature)
    2. then using the ZIP resource archive downloader step you can download and uncompress it into $ANDROID_HOME/ (specify this as the Extract path option of the step) - Note: the path ($ANDROID_HOME) depends on which program you used to create the ZIP! If you use Mac OS built in Finder -> Compress tool the generated ZIP will include the “licenses” directory in the ZIP, so you shouldn’t include it in the path when you extract it. If you use another tool you might have to include licenses in the path ($ANDROID_HOME/licenses), depending on whether your ZIP itself includes it or not.
  • Use a Script step and just echo into the files.

The license files are simple text/hash files, with a content like 8933bad161af4178b1185d1a37fbf41ea5269c55, so you can also do something like this with a Script step:

#!/bin/bash
set -ex
echo '8933bad161af4178b1185d1a37fbf41ea5269c55' > $ANDROID_HOME/licenses/android-sdk-license
echo 'd975f751698a77b662f1254ddbeed3901e976f5a' > $ANDROID_HOME/licenses/intel-android-extra-license

Of course, you will have to replace the license hashes when the license changes.

I tried the last solution and it worked for me only if I would add all these line especially mkdir:

            set -ex
            mkdir -p "${ANDROID_HOME}/licenses"
            echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
            echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license"
            echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "${ANDROID_HOME}/licenses/intel-android-extra-license"

I am posting it just in case it will help someone
(this solution is needed for constraint layout library otherwise it complains about licenses)

1 Like

You’re absolutely right @DeveloperExozet - thanks for sharing, I’ll update the licenses script ASAP!

Just one note - we just accepted a Pull Request which will include the 8933bad161af4178b1185d1a37fbf41ea5269c55 license by default in the default docker image, as well as a couple of preinstalled constrant-layout packages (after this weekend’s updates) - https://github.com/bitrise-docker/android/pull/68 - that should help in most cases.

Just a note: our current recommendation is to use the Install missing Android tools step, which should take care of these missing tools which require a license to be accepted: Android - automatic dependency installer (e.g. build-tools) step : Install missing Android tools

This did not work for me. The checksum value for android-sdk-license was not 8933ba… but rather d56f5187…

I had to do the following…

# Create Android SDK license acceptance files
mkdir -p "${ANDROID_HOME}/licenses"
echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "${ANDROID_HOME}/licenses/android-sdk-license"
echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license"
echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "${ANDROID_HOME}/licenses/intel-android-extra-license"
1 Like

Thanks for sharing @danielsmith_deutsch!