title: How to accept android library licenses automatically from command line?
body: <p>I am using gitlab-ci to build my android project. After lots of searching I found how to accept sdk licences. But I am getting licence not accepted error on <code>ConstraintLayout</code> library. Here is my <code>.gitlab-ci.yml</code>:</p>
  
  <pre><code>    image: openjdk:8-jdk
  
      variables:
      ANDROID_TARGET_SDK: "25"
      ANDROID_BUILD_TOOLS: "25.0.0"
      ANDROID_SDK_TOOLS: "24.4.1"
  
    before_script:
      - apt-get --quiet update --yes
      - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
      - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz
      - tar --extract --gzip --file=android-sdk.tgz
      - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TARGET_SDK}
      - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
      - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
      - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
      - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
      - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
      - export ANDROID_HOME=$PWD/android-sdk-linux
      - chmod +x ./gradlew
      - chmod +x ./copy_licenses.sh
    build:
      script:
        - ./copy_licenses.sh
        - ./gradlew assembleDebug
      artifacts:
        paths:
        - app/build/outputs/
  </code></pre>
  
  <p>I copyed my licence files to the <code>$ANDROID_HOME/licenses</code> with <code>copy_licenses.sh</code> :</p>
  
  <pre><code>    #!/bin/bash
      # fail if any commands fails
      set -e
      # debug log
      set -x
  
      cp -a "./android-licenses" "$ANDROID_HOME/licenses"
  </code></pre>
  
  <p>after executing this, I am getting this error:</p>
  
  <pre><code>    FAILURE: Build failed with an exception.
  
      * What went wrong:
      A problem occurred configuring project ':app'.
      &gt; You have not accepted the license agreements of the following SDK components:
        [Solver for ConstraintLayout 1.0.0-beta4, ConstraintLayout for Android 1.0.0-beta4].
        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
  
      * Try:
      Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
      BUILD FAILED
  </code></pre>
  
  <p>How to accept <code>ConstraintLayout 1.0.0-beta4</code> licence from command line?</p>