5

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
Ivan Rudnev
  • 380
  • 7
  • 12
  • A [quick search for the error message](https://stackoverflow.com/search?q=You+have+not+accepted+the+license+agreements+of+the+following+SDK++components%3A+Android+SDK+Build-Tools) turns up 57 existing questions with nearly the identical message (the only difference being the specific version number). Did none of them help? – Ken White Jan 04 '18 at 14:23
  • Most of them don't include Travis-CI and I think it's not my case. But I'm still searching. – Ivan Rudnev Jan 04 '18 at 14:28
  • The issue is with the Android SDK, not Travis. Read the error message. – Ken White Jan 04 '18 at 14:39

1 Answers1

8

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.

albodelu
  • 7,931
  • 7
  • 41
  • 84
  • 1
    Wow, I just added buildToolsVersion "27.0.2" to my app/build.gradle and it works!! Thanks a lot! – Ivan Rudnev Jan 07 '18 at 13:52
  • 1
    Your last suggestion under Note gives `The command "yes | sudo sdkmanager --licenses" failed and exited with 1 during .` – Gabor Jan 31 '18 at 00:41
  • I added a link to the note section, I never tried this option, thanks. – albodelu Jan 31 '18 at 00:47
  • Try to remove `sudo`, some Travis-ci builds doesn't support it based on your configuration. Ivan is using `sudo: required`. Anyway, if you manually specify a build tools version, you don't need this command in your related question. – albodelu Jan 31 '18 at 00:52
  • just verified that `- yes | sudo sdkmanager --licenses` does not work. The failure message is `Error: Unknown argument --licenses` – wMaN Sep 09 '21 at 07:15