2

I work in Android Project, I use gitlab.
I config gitlab-ci.yml file and I try to commit my Android Project but i have an issue in the gitLab pipeline.
I migrating my code and i'm trying to build my application but I receive erro below:

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: [ConstraintLayout for Android 1.0.2, Solver for ConstraintLayout 1.0.2]. 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

Total time: 2 mins 8.129 secs ERROR: Job failed: exit code 1

this is my gitlab-ci.yml file

image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "25"
ANDROID_BUILD_TOOLS: "25.0.2"
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_COMPILE_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
 - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
 - chmod +x ./gradlew
stages:
 - build
 - test
build:
 stage: build
 script:
 - ./gradlew assembleDebug
artifacts:
 paths:
  - app/build/outputs/
 unitTests:
stage: test
script:
 - ./gradlew test
functionalTests:
 stage: test
 script:
  - wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
- chmod +x android-wait-for-emulator
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter sys-img-x86-google_apis-${ANDROID_COMPILE_SDK}
- echo no | android-sdk-linux/tools/android create avd -n test -t android-${ANDROID_COMPILE_SDK} --abi google_apis/x86
- android-sdk-linux/tools/emulator64-x86 -avd test -no-window -no-audio &
- android update sdk --no-ui --filter build-tools-25.0.2,android-25,extra-android-m2repository
- ./android-wait-for-emulator
- adb shell input keyevent 82
- ./gradlew cAT
artifacts:
paths:
- app/build/reports/androidTests/
  • Possible duplicate of [Can't accept license agreement Android SDK Platform 24](https://stackoverflow.com/questions/40383323/cant-accept-license-agreement-android-sdk-platform-24) – secustor Jun 11 '17 at 15:58
  • my project build correctly in Android Studio, I don't use cordova, my problem is when i commit my project in gitlab, i recive this build error. – Nizar Abdelhedi Jun 11 '17 at 16:27
  • Have you tried the fix mentioned in the linked thread? – secustor Jun 11 '17 at 16:46

1 Answers1

0

add the following lines to end of before_script section

  - export SDK_MANAGER="${ANDROID_HOME}/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME}"
  - set +o pipefail
  - echo y | ${SDK_MANAGER} --licenses
  - set -o pipefail

a full before_script might looks like this

variables:
  ANDROID_COMPILE_SDK: "28"
  ANDROID_BUILD_TOOLS: "28.0.3"
  ANDROID_SDK_TOOLS:   "6609375_latest"

before_script:
  - echo ANDROID_COMPILE_SDK ${ANDROID_COMPILE_SDK}
  - echo ANDROID_BUILD_TOOLS ${ANDROID_BUILD_TOOLS}
  - echo ANDROID_SDK_TOOLS ${ANDROID_SDK_TOOLS}
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - export ANDROID_SDK_ROOT=$PWD/android-sdk-linux
  - export SDK_MANAGER="${ANDROID_SDK_ROOT}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT}"
  - echo y | ${SDK_MANAGER} "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | ${SDK_MANAGER} "platform-tools" >/dev/null
  - echo y | ${SDK_MANAGER} "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools/
  - chmod +x ./gradlew
  # temporarily disable checking for EPIPE error and use yes to accept all licenses
  - set +o pipefail
  - echo y | ${SDK_MANAGER} --licenses
  - set -o pipefail
Simon J. Liu
  • 787
  • 4
  • 11