Travis Ci Failed Because Cannot Accept License Constrain Layout

Travis CI failed because cannot accept license Constrain Layout

Updated response

is there any solution without workaround using export license?

Yes, you can use the new sdkmanager to install the constraint library and accept the license:

  - echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"

Otherwise, the missing component will be detected by gradle and downloaded without accept it:

  # Show version and download Gradle Wrapper if it's not already cached
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew --version
# Clean project and download missing dependencies and components
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew clean build

In that case, as explained below, you need to accept the license the first time via the workaround.

Full working sample using constraint-layout codelab repository for Android API level 22 to 25:

language: android
jdk: oraclejdk8
sudo: required # false for Container-Based Infrastructure, required for Sudo-enabled Infrastructure

before_cache:
- rm -f ${TRAVIS_BUILD_DIR}/gradle/caches/modules-2/modules-2.lock # Avoid to repack it due locks
- rm -f ${TRAVIS_BUILD_DIR}/gradle/caches/3.3/classAnalysis/classAnalysis.lock
- rm -f ${TRAVIS_BUILD_DIR}/gradle/caches/3.3/jarSnapshots/jarSnapshots.lock

cache:
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/

notifications:
email: false

android:
components: # Cookbooks version: https://github.com/travis-ci/travis-cookbooks/tree/9c6cd11
- tools # Update preinstalled tools from revision 24.0.2 to 24.4.1
- build-tools-25.0.2 # Match build-tools version used in build.gradle
- platform-tools # Update platform-tools to revision 25.0.3+
- tools # Update tools from revision 24.4.1 to 25.2.5

env:
global:
- DIR=constraint-layout-start # Project directory
- API=25 # Android API level 25 by default
- TAG=google_apis # Google APIs by default, alternatively use default
- ABI=armeabi-v7a # ARM ABI v7a by default
- QEMU_AUDIO_DRV=none # Disable emulator audio to avoid warning
- GRADLE_USER_HOME="${TRAVIS_BUILD_DIR}/gradle" # Change location for Gradle Wrapper and cache
- ANDROID_HOME=/usr/local/android-sdk-24.0.2 # Depends on the cookbooks version used in the VM
- TOOLS=${ANDROID_HOME}/tools # PATH order matters, exists more than one emulator script
- PATH=${ANDROID_HOME}:${ANDROID_HOME}/emulator:${TOOLS}:${TOOLS}/bin:${ANDROID_HOME}/platform-tools:${PATH}
- ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)

matrix:
include: # More Emulator API levels to build in parallel
- env: API=24
- env: API=23
- env: API=22
allow_failures:
- env: API=23
- env: API=22
fast_finish: false

before_install:
- export EMULATOR="system-images;android-${API};${TAG};${ABI}" # Used to install/create emulator
- echo 'count=0' > /home/travis/.android/repositories.cfg # Avoid warning

install:
# List and delete unnecessary components to free space
- sdkmanager --list || true
- sdkmanager --uninstall "system-images;android-15;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-16;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-17;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-18;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-19;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-21;default;armeabi-v7a"
- sdkmanager --uninstall "extras;google;google_play_services"
- sdkmanager --uninstall "extras;android;support"
- sdkmanager --uninstall "platforms;android-10"
- sdkmanager --uninstall "platforms;android-15"
- sdkmanager --uninstall "platforms;android-16"
- sdkmanager --uninstall "platforms;android-17"
- sdkmanager --uninstall "platforms;android-18"
- sdkmanager --uninstall "platforms;android-19"
- sdkmanager --uninstall "platforms;android-20"
- sdkmanager --uninstall "platforms;android-21"
- sdkmanager --uninstall "build-tools;21.1.2"
# Update sdk tools to latest version and install/update components
- echo yes | sdkmanager "tools"
- echo yes | sdkmanager "platforms;android-25" # Latest platform required by SDK tools
- echo yes | sdkmanager "platforms;android-${API}" # Android platform required by emulator
- echo yes | sdkmanager "extras;android;m2repository"
- echo yes | sdkmanager "extras;google;m2repository"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"
- echo yes | sdkmanager "$EMULATOR" # Install emulator system image
# Create and start emulator
- echo no | avdmanager create avd -n acib -k "$EMULATOR" -f --abi "$ABI" --tag "$TAG"
- emulator -avd acib -engine classic -no-window -camera-back none -camera-front none -verbose -qemu -m 512 &
# Start adbd, wait for device connected and show android serial
- adb wait-for-device get-serialno
# Show version and download Gradle Wrapper if it's not already cached
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew --version
# Clean project and download missing dependencies and components
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew clean build
# Check components status
- sdkmanager --list || true

before_script:
# Wait for emulator fully-booted and disable animations
- android-wait-for-emulator
- adb shell settings put global window_animation_scale 0 &
- adb shell settings put global transition_animation_scale 0 &
- adb shell settings put global animator_duration_scale 0 &
- sleep 30
- adb shell input keyevent 82 &

script:
# Run all device checks
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew connectedCheck

after_script:
# Show tests and lint results
- cat ${TRAVIS_BUILD_DIR}/${DIR}/*/build/outputs/androidTest-results/connected/*
- cat ${TRAVIS_BUILD_DIR}/${DIR}/*/build/reports/lint-results.xml

Two more samples using sdkmanager and avdmanager without ${DIR} workaround:

  • Android Maps Utils library - Google
  • Dexter library - Karumi

References

Official documentation related to Auto-download missing packages with Gradle

The new Emulator options are explained in Start the Emulator from the Command Line

avdmanager explained here replaces android avd since SDK tools version 25.3.0

sdkmanager explained here also enhanced to view and accept all licenses from the command line


Previous response: Since sdkmanager replaces android script

I'm a little outdated about Travis-ci and seems extra work is required now, so it's better you check:

  • As tir38 noticed, android tool is no longer supported. Instead, use sdkmanager...

  • Open issue and workarounds for this topic:

In your .travis.yml file add:

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"

Do not forgot to accept all the licences on the main android object:

android:
components:
# ...
licenses:
- android-sdk-license-.+
- '.+'
  • Another related issue and workaround:

If you are getting "Please install the missing components using the
SDK manager in Android Studio." error you can just install the missing
component with the sdkmanager command line tool:

echo y | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta4"
echo y | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta"
  • This article explaining contraint-layout problem for Circle-ci and Travis-ci

  • Documentation about sdkmanager provided in the Android SDK Tools package (25.2.3+)


Outdated solution: Before android script deprecation

I don't use the default Travis-ci script to install Android components and accept licenses, from here:

# Install and update SDK
function install-and-update-sdk {
# Keep SDK packages up-to-date (only missing suggested updates are installed).
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk -u -t \
${UPDATE_PKGS:-'platform-tools,tools,extra-android-m2repository,extra-google-m2repository'}
# Install or reinstall SDK packages (if empty, all packages are installed).
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk -a -u -t \
${INSTALL_PKGS:-'build-tools-23.0.3,android-23'},${TARGET_PKGS:-}
}

You can accept all the licenses at the same time if you do it like this:

# THE SETUP STAGE
# ---------------
# If you comment out this section, Travis CI will install for you the components you define here.
# Check your project requirements and the components included by default on Travis-ci VM images.
# Check required: https://github.com/google/iosched/blob/master/doc/BUILDING.md
# Check defaults: http://docs.travis-ci.com/user/languages/android/#Pre-installed-components

android:
components:
# Check Android SDK tools: http://developer.android.com/tools/sdk/tools-notes.html
# Check Android SDK Platform-tools: http://developer.android.com/tools/revisions/platforms.html
# Comment the lines below if the latest revisions of Android SDK Tools are included by default.
# - tools
# - platform-tools
# ...
licenses:
# Check licenses: http://docs.travis-ci.com/user/languages/android/#Dealing-with-Licenses
# By default Travis will accept all the licenses, but it's also possible to define a white list:
# White list current android-sdk-license revision.
# - 'android-sdk-license-5be876d5'
# White list all android-sdk-license revisions.
# - 'android-sdk-license-.+'
# White list all the licenses.
- '.+'

Travis-CI build failed, You have not accepted the license agreements

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:

  • Accept ConstraintLayout licenses · Issue #6617 · travis-ci/travis-ci
  • android - Automatically accept all SDK licences - Stack Overflow

Travis CI build doesn't work with Android Constraint Layout

Your build.gradle is attempting to pull in com.android.support.constraint:constraint-layout:1.0.0-alpha2. My SDK Manager only offers me 1.0.0-alpha1 (Rev 32 of the Android Support Repository). Perhaps Travis CI also only has 1.0.0-alpha1 as well.

Since I presume that you have 1.0.0-alpha2 working on your development machine, I am not quite certain what is going on here. There might be a glitch in the distribution packaging of the Android Support Repository or something.

Travis CI build doesn't find Android Constraint Layout

I think that you need to update tools after platform-tools due to codependencies like this:

android:
components:
- tools
- build-tools-25.0.2
- platform-tools
- tools

Try this simplified version of my related answer, if you install it via sdkmanager, it works, see 1 2 3.

language: android
jdk: oraclejdk8
sudo: required

android:
components: # Cookbooks version: https://github.com/travis-ci/travis-cookbooks/tree/9c6cd11
- tools # Update preinstalled tools from revision 24.0.2 to 24.4.1
- build-tools-25.0.2 # Match build-tools version used in build.gradle
- platform-tools # Update platform-tools to revision 25.0.3+
- tools # Update tools from revision 24.4.1 to 25.2.5

env:
global:
- API=25 # Android API level 25 by default
- TAG=google_apis # Google APIs by default, alternatively use default
- ABI=armeabi-v7a # ARM ABI v7a by default
- QEMU_AUDIO_DRV=none # Disable emulator audio to avoid warning
- ANDROID_HOME=/usr/local/android-sdk-24.0.2 # Depends on the cookbooks version used in the VM
- TOOLS=${ANDROID_HOME}/tools # PATH order matters, exists more than one emulator script
- PATH=${ANDROID_HOME}:${ANDROID_HOME}/emulator:${TOOLS}:${TOOLS}/bin:${ANDROID_HOME}/platform-tools:${PATH}
- ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)

before_install:
- export EMULATOR="system-images;android-${API};${TAG};${ABI}" # Used to install/create emulator
- echo 'count=0' > /home/travis/.android/repositories.cfg # Avoid warning

install:
# List and delete unnecessary components to free space
- sdkmanager --list || true
- sdkmanager --uninstall "system-images;android-15;default;armeabi-v7a"

# Update sdk tools to latest version and install/update components
- echo yes | sdkmanager "tools"
- echo yes | sdkmanager "platforms;android-25" # Latest platform required by SDK tools
- echo yes | sdkmanager "platforms;android-${API}" # Android platform required by emulator
- echo yes | sdkmanager "extras;android;m2repository"
- echo yes | sdkmanager "extras;google;m2repository"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"
- echo yes | sdkmanager "$EMULATOR" # Install emulator system image
# Create and start emulator
- echo no | avdmanager create avd -n acib -k "$EMULATOR" -f --abi "$ABI" --tag "$TAG"
- emulator -avd acib -engine classic -no-window -verbose -qemu -m 512 &

before_script:
# Wait for emulator fully-booted and disable animations
- android-wait-for-emulator
- adb shell settings put global window_animation_scale 0 &
- adb shell settings put global transition_animation_scale 0 &
- adb shell settings put global animator_duration_scale 0 &
- adb shell input keyevent 82 &

script:
- ./gradlew build connectedCheck

after_script:
- cat ${TRAVIS_BUILD_DIR}/*/build/outputs/androidTest-results/connected/*

Travis-CI Android SDK license problems

Replace

- ANDROID_BUILD_TOOLS=27.0.2

by

- ANDROID_BUILD_TOOLS=27.0.1

or add:

- echo yes | sdkmanager "build-tools;27.0.1"

to explicitly install the matching version and accept the license as commented here.

Explanation

Since Android Plugin for Gradle 3.0.0 (October 2017)

you no longer need to specify a version for the build tools—the plugin
uses the minimum required version by default. So, you can now remove
the android.buildToolsVersion property.

You are not specifying a version here, you are explicitly installing version 27.0.2, and Gradle is downloading version 27.0.1 without accepting the license agreement as explained here.

Alternatively add buildToolsVersion 27.0.2 to your app/build.gradle:

android {
compileSdkVersion 27
buildToolsVersion "27.0.2"

Note

Seems that it's possible to automatically accept all the licenses, and echo is no longer required:

- yes | sudo sdkmanager --licenses

But I didn't test it, please check this question for further information.

you might still need to copy the licence files to other locations
based on your setup.

Travis Ci build error caused by Android SDK license agreements

It seems that you have the google repository missing.

Add the - extra-google-m2repository and try the build again.

Here is my .travis.yml for reference:

language: android
android:
components:
- tools
- platform-tools
- build-tools-24.0.3
- android-24
- extra-android-m2repository
- extra-google-m2repository
- extra-android-support
- extra-google-google_play_services
jdk:
- oraclejdk8
script:
- ./gradlew test

Android O Gradle build fails with travis ci

I'm getting an Access denied error to your build log, and I didn't use it, but I'll try to answer you.

As announced here:

The Android Gradle Plugin 3.0.0-alpha3 was also released through
maven.google.com.

You can try to fix it by adding Google’s Maven Repository here like this:

buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Make sure that the repositories section includes a maven section with
the "https://maven.google.com" endpoint. For example:

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

As commented here, this version doesn't exist in Bintray JCenter:

com.android.tools.build.gradle
latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3

Also be sure to update build tools to the latest version as suggested in this related question:

Update your build tools from SDK manager

I add links to samples using the new sdkmanager command line here.

I would need a sample project reproducing the issue to check my suggestions.

Travis-CI Build error android app

Your build fails because you have not accepted licenses for Android SDK packages. Add this line to your travis.yml.

licenses:
- '.+'

EDIT :

Since your build now fails due to the error "No connected device". You must create an emulator in the travis and run the instrumentation tests on it.
Add these lines too in the travis.yml file.

env:
global:
- ANDROID_API_LEVEL=27
- ANDROID_EMULATOR_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=27.0.3
- ANDROID_ABI=armeabi-v7a
- ANDROID_TAG=google_apis
- ADB_INSTALL_TIMEOUT=20

Add these lines to the components section of the travis file.

 - android-$ANDROID_EMULATOR_LEVEL
- sys-img-armeabi-v7a-google_apis-$ANDROID_EMULATOR_LEVEL

Add these line too

before_script:
# Create and start emulator.
- echo no | android create avd --force -n test -t "android-"$ANDROID_EMULATOR_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG
- emulator -avd test -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &

Also, add this as the first line of travis.yml

sudo: false


Related Topics



Leave a reply



Submit