其他分享
首页 > 其他分享> > Travis-CI Android SDK许可证问题

Travis-CI Android SDK许可证问题

作者:互联网

我正在尝试用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,您明确安装版本27.0.2,Gradle正在下载版本27.0.1而不接受here中解释的许可协议.

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

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"

注意

似乎可以自动接受所有许可证,并且不再需要回应:

- yes | sudo sdkmanager --licenses

但我没有测试,请查看this question以获取更多信息.

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

标签:android,android-sdk-tools,travis-ci
来源: https://codeday.me/bug/20190607/1195435.html