【问题标题】:Travis-CI build failed, "You have not accepted the license agreements"Travis-CI 构建失败,“您尚未接受许可协议”
【发布时间】:2018-11-10 08:10:08
【问题描述】:

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

有没有办法解决这个问题?

【问题讨论】:

标签: android travis-ci


【解决方案1】:

接受所有许可的另一个选项如下:

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"

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

【讨论】:

【解决方案2】:

通过从 gradle 中删除 ConstraintLayout 依赖项来解决此问题,因为我并没有使用 ConstraintLayout。 Travis 似乎没有检测/接受 ConstraintLayout 的许可。

【讨论】:

    【解决方案3】:

    @schnatterer 的回答非常接近。如果不接受这些许可证,我就是无法让 SDK 27 工作:

    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 更新可能需要添加/替换新哈希。

    【讨论】:

      【解决方案4】:

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

      1. licenses 文件夹从 android SDK 目录复制到您的仓库(例如,我们将其命名为 android-licenses
      2. 将这些步骤添加到.travis.yml 文件的before_script: 部分下
      - mkdir -p "$ANDROID_HOME/licenses" - cp ./android-licenses/ "$ANDROID_HOME/licenses/"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-03
        • 2018-07-14
        • 2018-04-30
        • 2017-02-24
        • 2017-02-07
        • 1970-01-01
        • 1970-01-01
        • 2017-03-16
        相关资源
        最近更新 更多