特拉维斯-CI 构建失败,"You have not accepted the license agreements"



我具有以下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默认接受了所有许可,因此不应该发生。

有什么方法可以解决此问题?

接受所有许可证的另一个选项是:

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"

您可以在此处找到更多信息:

  • 接受约束许可证
  • Android-自动接受所有SDK许可证 - 堆栈溢出

通过从Gradle中删除约束layer的依赖性修复了此操作,因为我无论如何都没有使用ConstraintLayout。看来特拉维斯(Travis)未检测/接受约束layout的许可。

@schnatterer的答案非常接近。我只是在不接受这些许可的情况下无法让SDK 27工作:

before_install:
  - mkdir "$ANDROID_HOME/licenses" || true
  - echo -e "n8933bad161af4178b1185d1a37fbf41ea5269c55nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$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更新可能需要添加/替换新哈希。

您可以通过导出许可证文件来接受本地计算机上接受的所有许可

  1. 从Android SDK DIR复制licenses文件夹到您的存储库(例如,让我们命名android-licenses
  2. before_script:节下,将这些步骤添加到您的.travis.yml文件
    -MKDIR -P" $ android_home/许可"     -cp ./android-licenses/" $ android_home/licenses/"

相关内容

最新更新