From 8ecf74a2af87f7d5c4492f19f4116b60059a202f Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 5 Sep 2026 14:33:33 +0200 Subject: [PATCH] fix(ci): let the Android build scripts respect a caller-set ANDROID_HOME build-android.sh hardcoded `export ANDROID_HOME="$HOME/Android/Sdk"`, which discarded whatever the caller had set. In the builder image the SDK is at /opt/android-sdk and the job exports exactly that, so the script looked for an NDK under /root/Android/Sdk, found nothing, and the build died a minute in with "Android SDK not found" -- the first automatic `latest` APK build failed on this and nothing else. Now a default rather than an override, matching what test-player-conformance.sh already did. NDK_HOME likewise prefers an explicitly pinned ANDROID_NDK_HOME over guessing with `ls | head -1`, which is how CI pins an exact NDK revision. A missing SDK now fails immediately and says which variable to set, instead of letting `ls` print its own error and the real failure surface a minute later inside the tauri CLI. android-dev.sh had the same override and gets the same treatment. --- scripts/android-dev.sh | 2 +- scripts/build-android.sh | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/android-dev.sh b/scripts/android-dev.sh index 403ac873e..a115af429 100755 --- a/scripts/android-dev.sh +++ b/scripts/android-dev.sh @@ -7,7 +7,7 @@ echo "======================================" # Setup environment echo "Setting up environment..." source "$HOME/.cargo/env.fish" 2>/dev/null || source "$HOME/.cargo/env" || true -export ANDROID_HOME="$HOME/Android/Sdk" +export ANDROID_HOME="${ANDROID_HOME:-$HOME/Android/Sdk}" export NDK_HOME="$ANDROID_HOME/ndk/$(ls $ANDROID_HOME/ndk 2>/dev/null | head -1)" # Check prerequisites diff --git a/scripts/build-android.sh b/scripts/build-android.sh index 58fe5c9a5..e65620903 100755 --- a/scripts/build-android.sh +++ b/scripts/build-android.sh @@ -6,9 +6,26 @@ set -e # Source Rust environment source "$HOME/.cargo/env.fish" 2>/dev/null || source "$HOME/.cargo/env" 2>/dev/null || true -# Set Android environment variables -export ANDROID_HOME="$HOME/Android/Sdk" -export NDK_HOME="$ANDROID_HOME/ndk/$(ls "$ANDROID_HOME/ndk" | head -1)" +# Set Android environment variables. +# +# Defaults, not overrides. A developer's SDK is at ~/Android/Sdk, but CI runs in +# the builder image where it lives at /opt/android-sdk and the job sets +# ANDROID_HOME accordingly — hardcoding the home-directory path here silently +# discarded that and the build died with "Android SDK not found" a minute in. +# `test-player-conformance.sh` already had this right; this script did not. +export ANDROID_HOME="${ANDROID_HOME:-$HOME/Android/Sdk}" +export ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-$ANDROID_HOME}" + +if [ ! -d "$ANDROID_HOME/ndk" ]; then + echo "❌ No NDK directory at $ANDROID_HOME/ndk" >&2 + echo " Set ANDROID_HOME to your SDK location, or install the NDK." >&2 + exit 1 +fi + +# Respect an NDK the caller has already picked (CI pins an exact revision via +# ANDROID_NDK_HOME); otherwise take whatever is installed. +export NDK_HOME="${NDK_HOME:-${ANDROID_NDK_HOME:-$ANDROID_HOME/ndk/$(ls "$ANDROID_HOME/ndk" | head -1)}}" +export ANDROID_NDK_HOME="$NDK_HOME" echo "🤖 Building Android APK..." echo "Android SDK: $ANDROID_HOME"