特拉维斯CI因失败而无法接受许可限制布局 [英] Travis CI failed because cannot accept license Constrain Layout
问题描述
在我写这个问题之前,我已经搜索过关于这个问题的相同问题,他们确实导出了许可证,因为仍然使用约束布局的alpha版本。但是现在android已经发布了稳定版本的约束布局。我尝试了很多设置,但仍然失败。
我的最新 .travis.yml
语言:android
jdk:oraclejdk8
android:
组件:
- platform-tools
- tools#获取新的`repository-11.xml`
- tools#参见https://github.com/travis-ci/travis-ci/issues / 6040#issuecomment-219367943)
- build-tools-25.0.0
- android-25
#其他组件
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
许可证:
- 'android-sdk-preview-license-52d11cd2'
- ' '
- 'google-gdk-license - 。+'
脚本:
- ./gradlew clean build
,这是我的 build.gradle
apply plugin:'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25 .0.0'
defaultConfig {
applicationIdcom.package.my
minSdkVersion 16
targetSdkVersion 25
versionCode 6
versionName 1.3.1
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile ('proguard-android.txt'),'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
androidTestCompile('com.android.support.test.espresso: espresso-core:2.2.2',{
exclude group:'com.android.support',module:'support-annotations'
})
compile'com.android.support: appcompat-v7:25.1.1'
testCompile'junit:junit:4 .12'
compile'com.google.firebase:firebase-database:10.2.0'
compile'com.google.firebase:firebase-messaging:10.2.0'
compile'com .firebaseui:firebase-ui-database:1.2.0'
compile'com.android.support.constraint:constraint-layout:1.0.1'
compile'com.android.support:design:25.0 .0'
compile'org.sufficientlycure:html-textview:3.2'
compile'com.android.support:recyclerview-v7:25.2.0'
}
套用插件:'com.google.gms.google-services'
与这个设置我得到了这个错误
失败:生成失败,出现异常。
*出错:
配置项目':app'时发生问题。
>您尚未接受以下SDK组件的许可协议:
[适用于Android 1.0.1的ConstraintLayout,适用于ConstraintLayout 1.0.1的解决方案]。
在构建项目之前,您需要接受许可协议并使用Android Studio SDK Manager完成缺失组件的安装。
或者,要了解如何将许可协议从一个工作站传输到另一个工作站,请访问http://d.android.com/r/studio-ui/export-licenses.html
*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。
BUILD FAILED
总时间:1分55.975秒
命令./gradlew clean build退出1.
完成。您的构建退出了1.
是否有解决方案,没有使用导出许可证的解决方法?
更新回复
有没有解决方法使用出口许可证?
是的,您可以使用新的 sdkmanager
a href =https://travis-ci.org/albodelu/constraint-layout/jobs/220841506#L1601 =noreferrer>安装约束库并接受许可证:
- echo yes | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout; 1.0.2
- echo yes | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout-solver; 1.0.2
否则,缺少的组件将被 gradle
检测到并下载而不接受它:
#显示版本并下载Gradle Wrapper,如果它尚未被缓存的话
- cd $ {TRAVIS_BUILD_DIR} / $ {DIR}&& ./gradlew --version
#清理项目并下载缺失的依赖项和组件
- cd $ {TRAVIS_BUILD_DIR} / $ {DIR}&& ./gradlew clean build
在这种情况下,如下所述,您需要先接受许可证时间通过解决方法。
使用约束布局代码库的Android API级别为22到25的完整工作示例:
language:android
jdk:oraclejdk8
sudo:必需的#基于容器的基础架构,为启用Sudo的基础架构所必需的
before_cache:
- rm -f $ {TRAVIS_BUILD_DIR} / gradle / caches / modules-2 / modules-2.lock#避免重新包装它由于锁
- 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:
目录:
- $ {TRAVIS_BUILD_DIR} / gradle / caches /
- $ {TRAVIS_BUILD_DIR} / gradle / wrapper / dists /
通知:
电子邮件:false
android:
组件:#食谱版本:https://github.com/travis-ci/travis-cookbooks/tree/9c6cd11
- tools#将预安装的工具从版本24.0.2更新到24.4.1
- build-tools-25.0.2#匹配build.gradle中使用的build-tools版本
- platform-tools#更新platform-工具修订版本25.0.3+
- tools#修订版本24.4.1到25.2.5的工具
env:
global:
- DIR = constraint- layout-start#项目目录
- API = 25#默认为Android API级别25
- TAG = google_apis#默认为Google API,或者使用默认值
- ABI = armeabi-v7a#ARM ABI v7a默认
- QEMU_AUDIO_DRV = none#禁用模拟器音频以避免警告
- GRADLE_USER_HOME =$ {TRAVIS_BUILD_DIR} / gradle#更改Gradle Wrapper和缓存的位置
- ANDROID_HOME = / usr / local / android-sdk-24.0.2#取决于VM
中使用的食谱版本 - TOOLS = $ { ANDROID_HOME} / $ {TOOLID_HOME} / $ {TOOLS_HOME}:$ {TOOLS} / bin:$ {ANDROID_HOME} /工具#PATH命令很重要,存在多个仿真器脚本
- PATH = $ {ANDROID_HOME} / platform-tools:$ {PATH}
- ADB_INSTALL_TIMEOUT = 20#分钟(默认为2分钟)
矩阵:
包括:#更多并行构建的Emulator API级别
- 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}#用于安装/创建模拟器
- echo'count = 0'> /home/travis/.android/repositories.cfg#避免警告
安装:
#列出并删除不必要的组件以释放空间
- sdkmanager --list || true
- sdkmanager --uninstallsystem-images; android-15; default; armeabi-v7a
- sdkmanager --uninstallsystem-images; android-16; default; armeabi-v7a
- sdkmanager --uninstallsystem-images; android-17; default; armeabi-v7a
- sdkmanager --uninstallsystem-images; android-18; default; armeabi-v7a
-sdkmanager --uninstallsystem-images; android-19; default; armeabi-v7a
- sdkmanager --uninstallsystem-images; android-21; default; armeabi-v7a
- sdkmanager --uninstallextras; google; google_play_services
- sdkmanager --uninstallextras; android; support
- sdkmanager --uninstallplatforms; android-10
- sdkmanager - -uninstallplatforms; android-15
- sdkmanager --uninstallplatforms; android-16
- sdkmanager --uninstallplatforms; android-17
- sdkmanager --uninstall platforms; android-18
- sdkmanager --uninstallplatforms; android-19
- sdkmanager --uninstallplatforms; android-20
- s dkmanager --uninstallplatforms; android-21
- sdkmanager --uninstallbuild-tools; 21.1.2
#将sdk工具更新到最新版本并安装/更新组件
- 回声是| sdkmanager工具
- echo yes | sdkmanagerplatforms; android-25#SDK工具所需的最新平台
- echo yes | sdkmanagerplatforms; android - $ {API}#模拟器所需的Android平台
- echo yes | sdkmanagerextras; android; m2repository
- echo yes | sdkmanagerextras; google; m2repository
- echo yes | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout; 1.0.2
- echo yes | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout-solver; 1.0.2
- echo yes | sdkmanager$ EMULATOR#安装模拟器系统映像
#创建并启动模拟器
- echo no | avdmanager创建avd -n acib -k$ EMULATOR-f --abi$ ABI - 标记$ TAG
- 模拟器-avd acib -engine经典-no-window -camera-back无 - 摄像头前无-verbose -qemu -m 512&
#启动adbd,等待设备连接并显示android serial
- adb wait-for-device get-serialno
#显示版本并下载Gradle Wrapper(如果它尚未被缓存)
- cd $ {TRAVIS_BUILD_DIR} / $ {DIR}&& ./gradlew --version
#清理项目并下载缺失的依赖项和组件
- cd $ {TRAVIS_BUILD_DIR} / $ {DIR}&& ./gradlew clean build
#检查组件状态
- sdkmanager --list || true
before_script:
#等待模拟器完全启动并禁用动画
- android-wait-for-emulator
- adb shell设置放入全局window_animation_scale 0& amp ;
- adb shell设置放全局transition_animation_scale 0&
- adb shell设置放全局animator_duration_scale 0&
- sleep 30
- adb shell input keyevent 82&
脚本:
#运行所有设备检查
- cd $ {TRAVIS_BUILD_DIR} / $ {DIR}&& ./gradlew connectedCheck
after_script:
#显示测试和lint结果
- cat $ {TRAVIS_BUILD_DIR} / $ {DIR} / * / build / outputs / androidTest-results /已连接/ *
- cat $ {TRAVIS_BUILD_DIR} / $ {DIR} / * / build / reports / lint-results.xml
使用 sdkmanager
和 avdmanager
而无
- Android地图实用程序库 - Google .org / albodelu / Dexter / builds / 220847349rel =noreferrer> Dexter图书馆 - Karumi
参考文献
avdmanager
这里解释取代 android avd
自 SDK工具版本25.3.0
sdkmanager
这里解释也增强了查看和接受来自命令行的所有许可证
以前的响应:由于sdkmanager替换了android脚本,因此我对Travis-ci有些过时了,现在需要额外的工作,所以最好检查一下:
-
由于tir38 注意到 a>, android
工具不再受支持。请改用 sdkmanager
...
打开问题和变通办法
$ b
在您的中。
before_install:
- mkdir$ ANDROID_HOME / licenses || true
- echo -e\\\
8933bad161af4178b1185d1a37fbf41ea5269c55> $ ANDROID_HOME / licenses / android-sdk-license
- echo -e\\\
84831b9409646a918e30573bab4c9c91346d8abd> $ ANDROID_HOME / licenses / android-sdk-preview-license
不要忘记接受所有主要 android
对象上的许可证:
android:
组件:
#...
许可证:
- android-sdk-license - 。+
- '。+'
- 另一个相关问题和解决方法:
如果您收到请使用Android Studio中的
SDK管理器安装缺失的组件。错误,您可以使用sdkmanager命令行工具安装缺少的
组件:
echo y | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout; 1.0.0-beta4
echo y | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout-solver; 1.0.0-beta
< blockquote>
-
本文解释Circle-ci和Travis-ci的contrat-layout问题。
=https://developer.android.com/studio/command-line/sdkmanager.html#usage =noreferrer>有关Android SDK工具包(25.2.3+)中提供的sdkmanager的文档
$ h
$ b 过时的解决方案:在android脚本弃用之前
我不使用默认的Travis-ci脚本安装Android组件并接受许可证, from here :
$ b
#安装并更新SDK
函数install-and-update-sdk {
#使SDK包保持最新(仅安装缺少建议的更新)。
(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'}
#安装或重新安装SDK包(if空,所有软件包都已安装)。
(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: - }
}
#设置阶段
#---------------
#如果您注释掉本节,Travis CI会为您安装您定义的组件这里。
#在Travis-ci虚拟机映像上查看您的项目需求和默认包含的组件。
#请检查:https://github.com/google/iosched/blob/master/doc/BUILDING.md
#检查默认值:http://docs.travis-ci.com/user / languages / android /#预装组件
android:
组件:
#检查Android SDK工具:http://developer.android.com/tools/sdk /tools-notes.html
#检查Android SDK平台工具:http://developer.android.com/tools/revisions/platforms.html
#如果最新版本的Android SDK工具默认包含在内。
# - 工具
# - 平台工具
#...
许可证:
#检查许可证:http://docs.travis-ci.com/用户/语言/安卓/#与牌照交易
#默认情况下,Travis将接受所有牌照,但也可以定义一个白名单:
#白名单当前android-sdk-license修订版。
# - 'android-sdk-license-5be876d5'
#列出所有android-sdk许可证修订版。
# - 'android-sdk-license - 。''
#白名单列出所有许可证。
- '。+'
Before i write this question, i already search same question about this, they did export license because still use alpha version of constrain layout. But now android already release stable version of constrain layout. I tried a lot of setup but still failed..
my latest .travis.yml
language: android
jdk: oraclejdk8
android:
components:
- platform-tools
- tools # to get the new `repository-11.xml`
- tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
- build-tools-25.0.0
- android-25
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
script:
- ./gradlew clean build
and this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.package.my"
minSdkVersion 16
targetSdkVersion 25
versionCode 6
versionName "1.3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.android.support:design:25.0.0'
compile 'org.sufficientlysecure:html-textview:3.2'
compile 'com.android.support:recyclerview-v7:25.2.0'
}
apply plugin: 'com.google.gms.google-services'
with this setup i got this 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.1, Solver for ConstraintLayout 1.0.1].
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 55.975 secs
The command "./gradlew clean build" exited with 1.
Done. Your build exited with 1.
is there any solution without workaround using export license ?
解决方案 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:
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.
- '.+'
这篇关于特拉维斯CI因失败而无法接受许可限制布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
由于tir38 注意到 a>, android
工具不再受支持。请改用 sdkmanager
...
$ b
在您的
中。
before_install:
- mkdir$ ANDROID_HOME / licenses || true
- echo -e\\\
8933bad161af4178b1185d1a37fbf41ea5269c55> $ ANDROID_HOME / licenses / android-sdk-license
- echo -e\\\
84831b9409646a918e30573bab4c9c91346d8abd> $ ANDROID_HOME / licenses / android-sdk-preview-license
不要忘记接受所有主要
android
对象上的许可证:
android:
组件:
#...
许可证:
- android-sdk-license - 。+
- '。+'
- 另一个相关问题和解决方法:
如果您收到请使用Android Studio中的
SDK管理器安装缺失的组件。错误,您可以使用sdkmanager命令行工具安装缺少的
组件:echo y | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout; 1.0.0-beta4
echo y | sdkmanagerextras; m2repository; com; android; support; constraint; constraint-layout-solver; 1.0.0-beta
< blockquote>
- =https://developer.android.com/studio/command-line/sdkmanager.html#usage =noreferrer>有关Android SDK工具包(25.2.3+)中提供的sdkmanager的文档
本文解释Circle-ci和Travis-ci的contrat-layout问题。
$ h
$ b过时的解决方案:在android脚本弃用之前
我不使用默认的Travis-ci脚本安装Android组件并接受许可证, from here :
$ b#安装并更新SDK
函数install-and-update-sdk {
#使SDK包保持最新(仅安装缺少建议的更新)。
(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'}
#安装或重新安装SDK包(if空,所有软件包都已安装)。
(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: - }
}
#设置阶段
#---------------
#如果您注释掉本节,Travis CI会为您安装您定义的组件这里。
#在Travis-ci虚拟机映像上查看您的项目需求和默认包含的组件。
#请检查:https://github.com/google/iosched/blob/master/doc/BUILDING.md
#检查默认值:http://docs.travis-ci.com/user / languages / android /#预装组件
android:
组件:
#检查Android SDK工具:http://developer.android.com/tools/sdk /tools-notes.html
#检查Android SDK平台工具:http://developer.android.com/tools/revisions/platforms.html
#如果最新版本的Android SDK工具默认包含在内。
# - 工具
# - 平台工具
#...
许可证:
#检查许可证:http://docs.travis-ci.com/用户/语言/安卓/#与牌照交易
#默认情况下,Travis将接受所有牌照,但也可以定义一个白名单:
#白名单当前android-sdk-license修订版。
# - 'android-sdk-license-5be876d5'
#列出所有android-sdk许可证修订版。
# - 'android-sdk-license - 。''
#白名单列出所有许可证。
- '。+'
Before i write this question, i already search same question about this, they did export license because still use alpha version of constrain layout. But now android already release stable version of constrain layout. I tried a lot of setup but still failed..
my latest
.travis.yml
language: android jdk: oraclejdk8 android: components: - platform-tools - tools # to get the new `repository-11.xml` - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943) - build-tools-25.0.0 - android-25 # Additional components - extra-google-google_play_services - extra-google-m2repository - extra-android-m2repository licenses: - 'android-sdk-preview-license-52d11cd2' - 'android-sdk-license-.+' - 'google-gdk-license-.+' script: - ./gradlew clean build
and this is my
build.gradle
apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion '25.0.0' defaultConfig { applicationId "com.package.my" minSdkVersion 16 targetSdkVersion 25 versionCode 6 versionName "1.3.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.1.1' testCompile 'junit:junit:4.12' compile 'com.google.firebase:firebase-database:10.2.0' compile 'com.google.firebase:firebase-messaging:10.2.0' compile 'com.firebaseui:firebase-ui-database:1.2.0' compile 'com.android.support.constraint:constraint-layout:1.0.1' compile 'com.android.support:design:25.0.0' compile 'org.sufficientlysecure:html-textview:3.2' compile 'com.android.support:recyclerview-v7:25.2.0' } apply plugin: 'com.google.gms.google-services'
with this setup i got this 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.1, Solver for ConstraintLayout 1.0.1]. 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 55.975 secs The command "./gradlew clean build" exited with 1. Done. Your build exited with 1.
is there any solution without workaround using export license ?
解决方案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
andavdmanager
without${DIR}
workaround: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 replacesandroid 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, usesdkmanager
...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. - '.+'
这篇关于特拉维斯CI因失败而无法接受许可限制布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!