Licences for Android build tools not accepted

echo “Y” | /opt/android/sdk/tools/bin/sdkmanager “build-tools;26.0.2”

I added this step after my restore_cache step and before my gradlew dependencies step. This properly accepted and downloaded v26.0.2 build tools. Not a proper solution, but it works for now.

Hm. That workaround didn’t work for me:

Warning: Failed to find package “build-tools
[===                                    ] 10% Computing updates...              
Exited with code 1

But this did:

   - run:
       name: Approve license for build tools
       command: (echo y; echo y; echo y; echo y; echo y; echo y) | $ANDROID_HOME/tools/bin/sdkmanager --licenses

hat tip this person:

2 Likes

Tried all, only this one works, thank you!

Hi everyone,

Sorry about the problems that you are having with this. It seems that Google have amended one of the Android SDK licenses today, and that exposed a bug in how I wrote the license accepting script in our Dockerfie. I’ve updated the CircleCI 2.0 image to accept the licenses properly - https://github.com/circleci/circleci-images/commit/1ac3ee07c1142291cafaf74c21b04fed46016a57 - this was the bug - the SDK manager would not update all components because the licenses had not yet been accepted.

For CircleCI 1.0 users, @edenman’s comment is the best solution - Licences for Android build tools not accepted.

Sorry for the downtime you have had today because of this.

Marc

3 Likes

I am seeing a similar license issue but with [Android Support Repository]. My build error also just started happening today, and occurs even when I rebuild a previously passing build.

Another user posted this here, but I thought I’d see if these two issues were linked.

https://discuss.circleci.com/t/licenses-missing/17320

Hi Alan,

Is this still failing for you? It might have taken a while for the new Docker image to propagate around through our Docker caches.

Marc

I get this message

Checking the license for package Android SDK Platform 25 in /opt/android/sdk/licenses
License for package Android SDK Platform 25 accepted.
Preparing “Install Android SDK Platform 25 (revision: 3)”.
“Install Android SDK Platform 25 (revision: 3)” ready.
Finishing "Install Android SDK Platform 25 (revision: 3)“
Installing Android SDK Platform 25 in /opt/android/sdk/platforms/android-25
"Install Android SDK Platform 25 (revision: 3)” complete.
“Install Android SDK Platform 25 (revision: 3)” finished.
Checking the license for package Android Support Repository in /opt/android/sdk/licenses
Warning: License for package Android Support Repository not accepted.

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:
[Android Support Repository].
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

Current config.yml is:

version: 2
jobs:
  build:
    working_directory: ~/TabletopApp/TabletopRoleplayTool
    docker:
      # specify the version you desire here
      - image: circleci/android:api-23-alpha

    environment:
      JVM_OPTS: -Xmx3200m

    steps:
      - checkout:
          path: ~/TabletopApp

      # Download and cache dependencies
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" 

}}

      - run:
          name: chmod permissions
          command: chmod +x ./gradlew

      - run:
          name: Approve license for build tools
          command: (echo y; echo y; echo y; echo y; echo y; echo y) | 

$ANDROID_HOME/tools/bin/sdkmanager --licenses

      - run: 
          name: Download Dependencies
          command: ./gradlew androidDependencies

      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" 

}}

      # run tests!
      - run: 
          name: Run Tests
          command: ./gradlew lint test

      - store_artifacts:
          path: app/build/reports
          destination: reports

      - store_test_results:
          path: app/build/test-results

fails at “Approve license for build tools”

1 Like

Fixed on CircleCI side it seems.

Hi Marc,

It’s no longer failing for me! Appreciate the quick response.

Thanks,

Alan

1 Like

Hi Marc,
I have started having this issue while trying to run my ionic application using cordova run android from the command line. I have tried the license fix excepting it multiple times but I still receive the error. Here is what it looks like:

[23:33:02] lint finished in 1.99 s
Checking the license for package Android SDK Platform 26 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘android’.
    You have not accepted the license agreements of the following SDK components:
    [Android SDK Platform 26].
    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

@gettindatfoshow
Had the same problem, managed to resolve it with this:

dependencies:
override:
- echo y | android update sdk --no-ui --all --filter build-tools-26.0.2,android-26

instead of my original:

dependencies:
override:
- echo y | android update sdk --no-ui --all --filter build-tools-26.0.2

Exactly the same failure for me.
On CircleCI 2.0 and follow the tutorial https://circleci.com/docs/2.0/language-android/
@marc any suggestion?

@HereIsJohnny, where should I input the dependencies? I tried this, but not work
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-26-alpha
environment:
JVM_OPTS: -Xmx3200m
dependencies:
override:
- echo y | android update sdk --no-ui --all --filter build-tools-26.0.2,android-26
steps:

I’m on Circle CI 2.0 with a circleci/android:api-26-alpha image and a build step that installs the NDK bundle:

- run: sdkmanager --install "ndk-bundle" && yes | sdkmanager --licenses

I’m seeing the following, followed by an immediate build failure:

[=============================          ] 75% Computing updates...              
[=============================          ] 75% Computing updates...              
[=======================================] 100% Computing updates...             
All SDK package licenses accepted.

Exited with code 141

The docker image itself looks fine to me so I’m not really sure what could be causing it.

Has anyone found a workable solution for the time being?


SOLUTION: I have solved my issue. For others, the command needs to be split up into two separate run statements.

Does not work

- run: sdkmanager --install "ndk-bundle" && yes | sdkmanager --licenses

Works

- run: sdkmanager --install "ndk-bundle"
- run: sdkmanager --licenses
1 Like

What’s the error msg? Seems like you put it in the correct place.

Here is the full .yml file:

dependencies:
  override:
    - echo y | android update sdk --no-ui --all --filter build-tools-26.0.2,android-26

machine:
  environment:
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m  -XX:+HeapDumpOnOutOfMemoryError"'
    _JAVA_OPTIONS: "-Xms512m -Xmx1024m"
  java:
    version: oraclejdk8


test:
  override:
    - java -jar checkstyle-7.2-all.jar -c ./google_checks.xml `find . -name "*.java" | grep "/src/"`
    - (./gradlew build):
        timeout: 360

  post:
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/
    - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;

Checking the license for package Android SDK Platform 27 in /usr/local/android-sdk-linux/licenses
Warning: License for package Android SDK Platform 27 not accepted.

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:splashActivity’.

You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 27].
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

I am getting the same error.
My circle.yml looks like:

machine:
environment:
GRADLE_OPTS: ‘-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"’

dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter “tools,android-27,build-tools-26.0.2,platform-tools,extra-android-m2repository,extra-google-m2repository,extra-google-google_play_services”

cache_directories:
- /usr/local/android-sdk-linux/platforms/android-27
- /usr/local/android-sdk-linux/build-tools/26.0.2
- /usr/local/android-sdk-linux/extras/android/m2repository
test:
override:
# run unit tests
- ./gradlew test --continue -PpreDexEnable=false
# Just run unit tests on circleci, for instrumentation testing we currently use Local device
- cp -r splashActivity/build/outputs $CIRCLE_ARTIFACTS

There is an ugly workaround for this: Need to accept license agreement for Android tools?

Real fix must come from CircleCI. Until last Friday, updating Android SDK to 27 in pre was enough. Yesterday all the projects I’m working with right now got broken with no change at all.

For now, it seems you’ll have to do this ugly workaround to get your builds working again.

Using expect solved my problem.

thanks: http://vgaidarji.me/blog/2017/05/31/automatically-accept-android-sdkmanager-licenses/

This is very frustrating. Having the same issue and couldn’t find a solution… My config file:

version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-21-alpha
    environment:
      JVM_OPTS: -Xmx3200m
    steps:
      - checkout
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
#      - run:
#         name: Chmod permissions #if permission for Gradlew Dependencies fail, use this. 
#         command: sudo chmod +x ./gradlew
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - run:
          name: Run Compile
          command: ./gradlew :clean :nachos:test
      - store_test_results:
          path: app/build/test-results

Can anyone help? It is really hard to evaluate a tool if you can’t event do a basic setup properly.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.