Travis-CI Android SDK license problems

断了今生、忘了曾经 提交于 2019-11-30 05:40:32

问题


I'm trying to build my Android project with Travis and currently I'm getting error:

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].

I don't know how, but yesterday I could solve problem with that:

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

But now it doesn't help me. I will be grateful for any advice.

Here is build URL https://travis-ci.org/madsunrise/luna-mobile/jobs/325034903 and also I put travis.yml below

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

回答1:


Replace

- ANDROID_BUILD_TOOLS=27.0.2

by

- ANDROID_BUILD_TOOLS=27.0.1

or add:

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

to explicitly install the matching version and accept the license as commented here.

Explanation

Since 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.

You are not specifying a version here, you are explicitly installing version 27.0.2, and Gradle is downloading version 27.0.1 without accepting the license agreement as explained here.

Alternatively add buildToolsVersion 27.0.2 to your app/build.gradle:

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"

Note

Seems that it's possible to automatically accept all the licenses, and echo is no longer required:

- yes | sudo sdkmanager --licenses

But I didn't test it, please check this question for further information.

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



来源:https://stackoverflow.com/questions/48097228/travis-ci-android-sdk-license-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!