fuzzyworld

ai-chat-android-auto / commit

CI: fix SDK setup — validate download URL and pre-write licence hashes

83a6244083df9ebfe345579921d2b109c4bfdd53 · Pavel Safronov · 2026-05-14 21:05:48 -0700 · parents 81bb02c06228

CI: fix SDK setup — validate download URL and pre-write licence hashes

- wget --fail --show-error so a 404 is visible instead of silently
  downloading an HTML error page as a zip
- Pre-write android-sdk-license and android-sdk-preview-license hash
  files instead of piping yes to sdkmanager --licenses, which is
  unreliable without a TTY

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

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fb8b74f..e4bd6d8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -33,7 +33,8 @@ build:
     - |
       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 \
+        wget --fail --show-error -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
@@ -41,8 +42,10 @@ build:
         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
+    # Pre-accept licences by writing the known SHA1 hashes (more reliable than `yes | sdkmanager --licenses`)
+    - mkdir -p "$ANDROID_HOME/licenses"
+    - printf '\n24333f8a63b6825ea9c5514f83c2829b004d1fee\nd56f5187479451eabf01fb78af6dfcb131a6481e\n8933bad161af4178b1185d1a37fbf41ea5269c55' > "$ANDROID_HOME/licenses/android-sdk-license"
+    - printf '\n84831b9409646a918e30573bab4c9c91346d8abd\n504667f4c0de7af1a06de9f4b1727b84351f2910' > "$ANDROID_HOME/licenses/android-sdk-preview-license"
     - sdkmanager "platforms;android-34" "build-tools;34.0.0" "platform-tools"
     # Write signing config
     - chmod +x ./gradlew