qsgfesqk
qsgfesqk

Reputation: 63

Gitlab CI - Android Sdk tools?

I use this Link for add gitlab CI in my android project. The CI work but I don't understand this part :

ANDROID_SDK_TOOLS:   "4333796"

In the tutorial, android SDK tool is the last version available.

ANDROID_SDK_TOOLS is a little funny. It's what version of the command line tools we're going to download from the official site. So, that number really just comes from the latest version available there.
Installing packages.

But when click on the link, they send me in android studio download page.

How can i find the version code to put here ? Is it important to change it ?

I also tried with sdkmanager.bar --list in SDK > tool > bin directory

ERROR: JAVA_HOME is set to an invalid directory: D:\Software\JDK\openjdk-15_windows-x64_bin\jdk-15\bin

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Upvotes: 5

Views: 1754

Answers (1)

Hamburg is nice
Hamburg is nice

Reputation: 397

At the download page you'll find the "Command line tools only" section. The file name ends with the version number. As of now this is: 8092744 (it'll change in the future).

enter image description here

The name of the download URL and the zipped directory have been changed though, so you'll need to update your ci file accordingly. Using the template in the linked tutorial, the file could look like this (I only build a debug apk, you can add release versions too ofc, just like in the tutorial):

image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "31"
  ANDROID_BUILD_TOOLS: "29.0.2"
  ANDROID_SDK_TOOLS:   "8092744"

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/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ "platform-tools" >/dev/null
  - echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ "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/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ --licenses
  - yes | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=/builds/pauni/lara/android-sdk-linux --licenses
  - set -o pipefail

stages:
  - build

assembleDebug:
  stage: build
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
    - app/build/outputs/

Upvotes: 3

Related Questions