Unpack the Android tools where sdkmanager expects to find them
🚴 Build and Test BikeControl / Workspace tests (push) Failing after 4m32s
🚴 Build and Test BikeControl / Android compile check (push) Skipped

The image had never been built successfully, which is why the registry
has never held it and why every CI run since the workflows landed died
at the pull.

The commandlinetools zip carries a single top-level `cmdline-tools/`.
Unzipping it straight into $ANDROID_HOME therefore lands `bin/` exactly
where `latest/` has to go, and the `mv cmdline-tools/cmdline-tools/*`
that followed matched nothing:

    mv: cannot stat '/opt/android-sdk/cmdline-tools/cmdline-tools/*'

So unpack into /tmp and move that directory into place instead.
sdkmanager derives the SDK root from its own path and refuses to run
from anywhere but cmdline-tools/latest/, so the layout is not cosmetic —
and a `test -x` on it now fails the build here rather than three layers
later, where the error is a licence prompt that never returns.

Verified in the pushed image: node 20.20.2, npm 10.8.2, jq 1.7, JDK 17,
tauri-cli 2.11.4, NDK 27.0.11902837, and all three Android targets.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-20 22:48:32 +02:00
co-authored by Claude Opus 5
parent c7bb60c666
commit da8ad4c1b3
+10 -4
View File
@@ -78,11 +78,17 @@ RUN . "$CARGO_HOME/env" && cargo install tauri-cli --locked --version "^2"
RUN mkdir -p "$ANDROID_HOME" /root/.android && \
printf '### User Sources for `android` cmd line tool ###\ncount=0\n' > /root/.android/repositories.cfg && \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/cmdline-tools.zip && \
unzip -q /tmp/cmdline-tools.zip -d "$ANDROID_HOME" && \
# The zip holds a single top-level cmdline-tools/, and sdkmanager insists on
# living in cmdline-tools/latest/ — it derives the SDK root from its own
# path and refuses to run from anywhere else. So unpack somewhere neutral
# and move that directory into place; unzipping straight into $ANDROID_HOME
# puts bin/ where latest/ has to go.
unzip -q /tmp/cmdline-tools.zip -d /tmp/cmdline-tools && \
rm /tmp/cmdline-tools.zip && \
mkdir -p "$ANDROID_HOME/cmdline-tools/latest" && \
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools/"* "$ANDROID_HOME/cmdline-tools/latest/" && \
rmdir "$ANDROID_HOME/cmdline-tools/cmdline-tools"
mkdir -p "$ANDROID_HOME/cmdline-tools" && \
mv /tmp/cmdline-tools/cmdline-tools "$ANDROID_HOME/cmdline-tools/latest" && \
rmdir /tmp/cmdline-tools && \
test -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
# Licences up front so Gradle never blocks on a prompt in CI.
RUN yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_HOME" --licenses > /dev/null