2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-28 12:47: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
variables:
ANDROID_COMPILE_SDK: "31"
ANDROID_BUILD_TOOLS: "30.0.3"
ANDROID_SDK_TOOLS: "6609375"
ANDROID_COMPILE_SDK: "33"
ANDROID_BUILD_TOOLS: "34.0.0"
ANDROID_SDK_TOOLS: "10406996"
before_script:
# Prepare system for use of sdkmanager
- 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-6609375_latest.zip
- unzip -d cmdline-tools android-sdk.zip
- echo y | cmdline-tools/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
- echo y | cmdline-tools/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | cmdline-tools/tools/bin/sdkmanager "patcher;v4" >/dev/null
- echo y | cmdline-tools/tools/bin/sdkmanager "emulator" >/dev/null
- echo y | cmdline-tools/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | cmdline-tools/tools/bin/sdkmanager "tools" >/dev/null
- echo y | cmdline-tools/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
- export ANDROID_HOME=$PWD/cmdline-tools
- export PATH=$PATH:$PWD/cmdline-tools/platform-tools/
- chmod +x ./gradlew
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip
# Create the directory structure around cmdline-tools that sdkmanager is expecting
- mkdir -p sdk/cmdline-tools
- unzip android-sdk.zip
- mv cmdline-tools sdk/cmdline-tools/latest
# Update the environment
- export ANDROID_HOME=$PWD/sdk
- export PATH=$PATH:$PWD/sdk/cmdline-tools/latest/bin
# (this line should fail if sdkmanager is moved out of that directory in the future)
- type sdkmanager
# Install SDK packages
- 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
- set +o pipefail
- yes | cmdline-tools/tools/bin/sdkmanager --licenses
# Gradle will automatically download parts of the SDK if they are missing,
# 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"
- yes | sdkmanager --licenses
# Re-enable checking for EPIPE and allow execution of Gradle wrapper script
- set -o pipefail
- chmod +x ./gradlew
stages:
- build