fuzzyworld

ai-chat-android-auto / commit

CI: switch to eclipse-temurin:17 with fresh Android SDK setup

81bb02c06228baa6da3637b25ec5bb524f4e7af9 · Pavel Safronov · 2026-05-14 21:01:52 -0700 · parents 753fa7b60a81

CI: switch to eclipse-temurin:17 with fresh Android SDK setup

The jangrewe image's bundled sdkmanager crashes at 25% due to a JDK
incompatibility. Switch to eclipse-temurin:17-jdk-focal, download the
Android command-line tools directly, and cache the SDK dir so subsequent
runs skip the download.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
 .gitlab-ci.yml | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d76837e..fb8b74f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,14 +12,39 @@ stages:
   - build
   - release
 
+variables:
+  ANDROID_HOME: "$CI_PROJECT_DIR/.android-sdk"
+  ANDROID_SDK_ROOT: "$CI_PROJECT_DIR/.android-sdk"
+
 build:
   stage: build
-  image: jangrewe/gitlab-ci-android:latest
+  image: eclipse-temurin:17-jdk-focal
   rules:
     - if: $CI_COMMIT_TAG
+  cache:
+    key: android-sdk-gradle
+    paths:
+      - .android-sdk/
+      - .gradle/
   before_script:
-    - yes | sdkmanager --licenses
-    - sdkmanager "platforms;android-34" "build-tools;34.0.0"
+    # Install OS tools
+    - apt-get update -qq && apt-get install -y -qq unzip wget curl
+    # Download Android command-line tools if not restored from cache
+    - |
+      if [ ! -f "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then
+        echo "Downloading Android command-line tools..."
+        wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip \
+             -O /tmp/cmdline-tools.zip
+        mkdir -p "$ANDROID_HOME/cmdline-tools"
+        unzip -q /tmp/cmdline-tools.zip -d /tmp/ct
+        mv /tmp/ct/cmdline-tools "$ANDROID_HOME/cmdline-tools/latest"
+        rm -rf /tmp/cmdline-tools.zip /tmp/ct
+      fi
+    - export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
+    # Accept licences and install SDK components
+    - yes | sdkmanager --licenses > /dev/null
+    - sdkmanager "platforms;android-34" "build-tools;34.0.0" "platform-tools"
+    # Write signing config
     - chmod +x ./gradlew
     - echo "$KEYSTORE_BASE64" | base64 -d > keystore.jks
     - echo "release.storeFile=../keystore.jks"               > local.properties
@@ -38,10 +63,6 @@ build:
     paths:
       - app/build/outputs/apk/release/app-release.apk
     expire_in: 30 days
-  cache:
-    key: gradle
-    paths:
-      - .gradle/
 
 release:
   stage: release