2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +00:00

Match SDK versions in CI with current requirements

## Summary

This fixes execution on gitlab. The newer version of `sdkmanager` has
different expectations, so we now create a directory for the SDK first
and move `cmdline-tools` into that.

Other changes:
- More inline comments
- Cmdline tools (like sdkmanager) added to path
- Platform tools (like adb) removed from path
- 'patcher' is no longer installed
This commit is contained in:
Philip Cohn-Cort 2023-11-17 16:00:31 +00:00
parent f16981ffbb
commit 22b6427a18

View File

@ -10,37 +10,37 @@
image: eclipse-temurin:17-jdk-focal image: eclipse-temurin:17-jdk-focal
variables: variables:
ANDROID_COMPILE_SDK: "31" ANDROID_COMPILE_SDK: "33"
ANDROID_BUILD_TOOLS: "30.0.3" ANDROID_BUILD_TOOLS: "34.0.0"
ANDROID_SDK_TOOLS: "6609375" ANDROID_SDK_TOOLS: "10406996"
before_script: before_script:
# Prepare system for use of sdkmanager
- apt-get --quiet update --yes - apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 - 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-6609375_latest.zip - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip
- unzip -d cmdline-tools android-sdk.zip # Create the directory structure around cmdline-tools that sdkmanager is expecting
- echo y | cmdline-tools/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null - mkdir -p sdk/cmdline-tools
- echo y | cmdline-tools/tools/bin/sdkmanager "platform-tools" >/dev/null - unzip android-sdk.zip
- echo y | cmdline-tools/tools/bin/sdkmanager "patcher;v4" >/dev/null - mv cmdline-tools sdk/cmdline-tools/latest
- echo y | cmdline-tools/tools/bin/sdkmanager "emulator" >/dev/null # Update the environment
- echo y | cmdline-tools/tools/bin/sdkmanager "platform-tools" >/dev/null - export ANDROID_HOME=$PWD/sdk
- echo y | cmdline-tools/tools/bin/sdkmanager "tools" >/dev/null - export PATH=$PATH:$PWD/sdk/cmdline-tools/latest/bin
- echo y | cmdline-tools/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null # (this line should fail if sdkmanager is moved out of that directory in the future)
- export ANDROID_HOME=$PWD/cmdline-tools - type sdkmanager
- export PATH=$PATH:$PWD/cmdline-tools/platform-tools/ # Install SDK packages
- chmod +x ./gradlew - echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
- echo y | sdkmanager "platform-tools" >/dev/null
- echo y | sdkmanager "emulator" >/dev/null
- echo y | sdkmanager "platform-tools" >/dev/null
- echo y | sdkmanager "tools" >/dev/null
- echo y | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
# temporarily disable checking for EPIPE error and use yes to accept all licenses # temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail - set +o pipefail
- yes | cmdline-tools/tools/bin/sdkmanager --licenses - yes | sdkmanager --licenses
# Gradle will automatically download parts of the SDK if they are missing, # Re-enable checking for EPIPE and allow execution of Gradle wrapper script
# assuming the licenses are accepted. Even if you don't need it to download
# anything, it will fail if it detects the liceses are not accepted.
# https://developer.android.com/studio/intro/update.html#download-with-gradle
# Unfortunately, it looks for the license acceptances in a different location than
# the sdkmanager creates them!
# Copy them to the location Gradle expects to find them to make everything run smoothly.
- cp -ap "${PWD}/licenses" "${PWD}/cmdline-tools/licenses"
- set -o pipefail - set -o pipefail
- chmod +x ./gradlew
stages: stages:
- build - build