Travis-CI Android SDK许可问题

Travis-CI Android SDK license problems

我正在尝试使用 Travis 构建我的 Android 项目,目前出现错误:

A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK 
components:
[Android SDK Build-Tools 27.0.1].

我不知道怎么做,但昨天我可以解决问题:

before_install:
    - yes | sdkmanager "platforms;android-27"

但现在它对我没有帮助。如有任何建议,我将不胜感激。

这是构建 URL https://travis-ci.org/madsunrise/luna-mobile/jobs/325034903 并且我把 travis.yml 放在下面

sudo: required

language: android
jdk: oraclejdk8

notifications:
  email:
    recipients:
      - rudnev.vanya@gmail.com
    on_success: change
    on_failure: always

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -rf $HOME/.gradle/caches/*/plugin-resolution/

before_install:
  - yes | sdkmanager "platforms;android-27"

cache:
  directories:
  - $HOME/.gradle/caches/
  - $HOME/.gradle/wrapper/
  - $HOME/.android/build-cache

env:
 global:
 - ANDROID_API=27
 - ANDROID_BUILD_TOOLS=27.0.2

android:
 components:
  - tools
  - tools # Running this twice get's the latest build tools
  - platform-tools
  - android-${ANDROID_API}
  - build-tools-${ANDROID_BUILD_TOOLS}
  - extra

script:
   - ./gradlew clean test build

替换

- ANDROID_BUILD_TOOLS=27.0.2

来自

- ANDROID_BUILD_TOOLS=27.0.1

或添加:

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

明确安装匹配版本并接受评论中的许可 here.

说明

因为 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.

您没有指定版本 here, you are explicitly installing version 27.0.2, and Gradle is downloading version 27.0.1 without accepting the license agreement as explained

或者将 buildToolsVersion 27.0.2 添加到您的 app/build.gradle:

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"

似乎可以自动接受所有许可证,不再需要 echo:

- yes | sudo sdkmanager --licenses

但我没有测试,请查看了解更多信息。

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