我有以下Travis-CI配置:
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
当它尝试构建时,我收到以下错误:
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.
现在,根据travis文档的说法,travis默认接受所有许可,因此不应该这样做。
有什么方法可以解决这个问题吗?
答案 0 :(得分:2)
接受所有许可的另一个选择如下:
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"
您可以在此处找到更多信息:
答案 1 :(得分:0)
通过从gradle中删除ConstraintLayout依赖项来解决此问题,因为我还没有使用ConstraintLayout。似乎Travis没有检测到/接受ConstraintLayout的许可证。
答案 2 :(得分:0)
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"
这会添加旧的和新的(26.0.2+)SDK许可证sha1
<强>解释强>
Android SDK要求您接受其许可协议。因此,它期望$ANDROID_HOME/licenses
中的文件具有许可证的名称。该文件的内容是sha1哈希(我猜)接受的协议版本(每行哈希)。一种技术方式,说明我理解并接受此特定版本的许可协议。协议有时会发生变化,因此SDK更新可能需要添加/替换新的哈希值。
答案 3 :(得分:-1)
您可以通过导出许可证文件
接受您在本地计算机上接受的所有许可证licenses
文件夹复制到您的仓库(例如,我们将其命名为android-licenses
).travis.yml
部分before_script:
文件中
醇>
- mkdir -p "$ANDROID_HOME/licenses" - cp ./android-licenses/ "$ANDROID_HOME/licenses/"