0

I'm trying to setup gitlab CI and I can't find any information about error which I'm getting from gitlab runner. Here is .yml file :

image: openjdk:8-jdk

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

 before_script:
    - 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/sdk-tools-linux-4333796.zip
- unzip -q android-sdk.zip -d android-sdk-linux
- 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/

And finaly error is:

Processing triggers for libc-bin (2.24-11+deb9u3) ...
$ wget --quiet --output-document=android-sdk.zip 
https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
$ unzip -q android-sdk.zip -d android-sdk-linux
$ echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all 
--filter android-${ANDROID_COMPILE_SDK}
************************************************************************* 
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Unrecognized argument --silent
ERROR: Job failed: exit code 1

What should I do in this case? Can't find any information about this. I have tried to change path but won't help.

4 Answers 4

0

If you want just build your project (with unit tests stage) you can try simple gitlab CI script which i'm using in my project gitlab snippet.

I'm not sure that this will work with build tools version 28, but you can experiment with this params.

0

You need to use sdkmanager to setup Android SDK, instead of deprecated "android" command.

Here is an example how I setup Android SDK in my Docker file

0

Try this commands and make sure you changed the compile sdk versions according to your APP, GITLAB CI configuration should be changed when the APP gradle configs changed.

image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "26"
  ANDROID_BUILD_TOOLS: "28.0.3"
  ANDROID_SDK_TOOLS:   "4333796"

before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- 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/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
- unzip -d android-sdk-linux android-sdk.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew
# temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses
- set -o pipefail

cache:
  paths:
  - .gradle/wrapper
  - .gradle/caches
  - android-sdk

stages:
- build

assembleDebug:
  stage: build
  script:
  - ./gradlew assembleDebug
  artifacts:
    paths:
    - app/build/outputs/
1
  • 1
    ANDROID_SDK_TOOLS: "28.0.3" ANDROID_SDK_TOOLS: "4333796" Does anybody know how to convert SDK Tool Version to the number?
    – Akira Chen
    Jul 11, 2022 at 9:35
0

For information GitLab provides up-to-date templates for various dev environment here: https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/

For android project : https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Android.latest.gitlab-ci.yml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.