Circleci android accept licenses

I saw that this question has been posted numerous times on this website but also others. There seems to be a broad problem with accepting the licenses in Android. And currently this is witholding me in using CircleCI.

This is how the first part of my .yaml config looks like:

version: 2.0

defaults: &defaults
  docker:
    - image: circleci/android:api-27-alpha
  working_directory: ~/ninetydays
  environment:
    _JAVA_OPTIONS: "-Xmx1400m"
    TERM: dumb

update_sdk: &update_sdk
  name: Update SDK
  command: |
    mkdir -p "$ANDROID_HOME/licenses" || true
    rsync -avhP ./android-licenses/ "$ANDROID_HOME/licenses/"

jobs:
  build:
    <<: *defaults
    steps:
      - run:
          <<: *update_sdk
      - checkout

I got a directory in my project with the latest hashes of the licenses for Android. But even though I copy them to the license directory I still get the following error:

Checking the license for package Android SDK Build-Tools 26.0.2 in /usr/local/android-sdk-
linux/licenses
Warning: License for package Android SDK Build-Tools 26.0.2 not accepted.
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.

* What went wrong: 
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 26.0.2, Android SDK Platform 27].

I’ve also tried the following update_sdk command:

update_sdk: &update_sdk
  name: Update SDK
  command: |
    mkdir -p "$ANDROID_HOME/licenses" || 
    echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_SDK/licenses/android-sdk-license"
    echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> "$ANDROID_SDK/licenses/android-    sdk-license"
    echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" >>"$ANDROID_SDK/licenses/android-sdk-preview-license"
    sdkmanager "platform-tools" "platforms;android-27"

But this ain’t working either, anyone has any idea how to solve this?

2 Likes

Same for me with version 1

I didn’t need to do this on Circle, but I did on Travis CI… I had a very similar setup to what you pasted, except try changing “$ANDROID_SDK” to “$ANDROID_HOME”. On Circle, I just needed to make sure I accepted the license agreement locally before pushing.

So you shouldn’t need it indeed. But it’s not working with or without. There’s going something wrong, with all my projects whilst having the same configuration as other projects. I’m really out of options.

Btw, replacing ANDROID_SDK to ANDROID_HOME didn’t work.

I’ve been able to fix it. It had nothing to do with the licenses stuff, this isn’t necessary anymore since the docker image already takes care of this now.

My problem was that my config file was named: config.yaml while it should have been config.yml. Oops.

1 Like