4

I have the following Travis-CI configuration:

language: android
jdk: oraclejdk8
android:
  components:
  - build-tools-22.0.1
  - android-22
  - extra-google-m2repository
before_install:
- openssl aes-256-cbc -K $encrypted_8bf9e2e639dc_key -iv $encrypted_8bf9e2e639dc_iv
  -in secrets.tar.enc -out secrets.tar -d
- tar xvf secrets.tar
- chmod +x gradlew

When it tries to build i get the following error:

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:
  [ConstraintLayout for Android 1.0.0-alpha7, Solver for ConstraintLayout 1.0.0-alpha7].
  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
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 17.927 secs
The command "./gradlew build connectedCheck" exited with 1.
Done. Your build exited with 1.

Now, from what the travis documentation says, travis accepts all licenses by default, so this should not be happening.

Is there any way to resolve this?

Bernd
  • 779
  • 5
  • 11
  • A very similar if not the same, here, and with some answers: https://stackoverflow.com/questions/42731625/travis-ci-failed-because-cannot-accept-license-constrain-layout/45622155#45622155 – Bruno Campos Oct 11 '17 at 19:34

4 Answers4

2

Another option for accepting all licenses is the following:

before_install:
  - mkdir "$ANDROID_HOME/licenses" || true
  - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
  - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

You can find more on this here:

schnatterer
  • 7,525
  • 7
  • 61
  • 80
  • This can be done with sdkmanager in more recent versions of the Android SDK. See https://stackoverflow.com/a/48125084/274350 – Richard Neish Jan 12 '18 at 14:37
0

Fixed this by removing the ConstraintLayout dependency from gradle since i didn't use the ConstraintLayout anyways. It seems that Travis does not detect / accept the license for the ConstraintLayout.

Bernd
  • 779
  • 5
  • 11
0

@schnatterer's answer was very close. I just couldn't get SDK 27 to work without accepteting these licenses:

before_install:
  - mkdir "$ANDROID_HOME/licenses" || true
  - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
  - echo -e "\n504667f4c0de7af1a06de9f4b1727b84351f2910" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

This adds the old and new (26.0.2+) SDK license sha1

Explanation:

The Android SDK requires you to accept their license agreements. Therefore it expects files in $ANDROID_HOME/licenses with the name of the license. The content of the file are sha1 hashes (I guess) of the accepted agreements versions (a hash each line). A technical way of saying I understand and accept this SPECIFIC version of the license agreements. From time to time the agreements change, so a SDK update might require to add/replace a new hash.

Patrick
  • 33,984
  • 10
  • 106
  • 126
-1

You can accept all licenses that you have accepted on your local machine by exporting license files

  1. Copy licenses folder from android SDK dir to your repo (let's name it android-licenses for example)
  2. Add these steps to your .travis.yml file under before_script: section
     - mkdir -p "$ANDROID_HOME/licenses"
     - cp ./android-licenses/ "$ANDROID_HOME/licenses/"
fo2rist
  • 1,903
  • 15
  • 22