From 7e3c933bef7200a661b3d8426a3fc51b5b07ea1c Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Tue, 26 May 2026 18:57:26 +0200 Subject: [PATCH] define ndk in gradle props --- .github/workflows/build.yml | 10 +++++++++- apps/weblibre/android/build.gradle | 2 +- apps/weblibre/android/gradle.properties | 1 + native/go_mobile_runtime/README.md | 7 ++++--- native/go_mobile_runtime/scripts/build-android.sh | 12 +++++++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 99ddfd84..b4e2c8b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,6 @@ jobs: KEY_PATH: ${{ github.workspace }}/apps/weblibre/key.jks KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} - ANDROID_NDK_VERSION: 28.2.13676358 permissions: contents: write steps: @@ -41,6 +40,14 @@ jobs: - name: Install Android NDK run: | set -euo pipefail + ANDROID_NDK_VERSION="$( + sed -n 's/^weblibre\.ndkVersion[[:space:]]*=[[:space:]]*//p' \ + apps/weblibre/android/gradle.properties + )" + if [[ -z "$ANDROID_NDK_VERSION" ]]; then + echo "Missing weblibre.ndkVersion in apps/weblibre/android/gradle.properties" >&2 + exit 1 + fi set +e yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install "ndk;$ANDROID_NDK_VERSION" sdkmanager_status=${PIPESTATUS[1]} @@ -50,6 +57,7 @@ jobs: fi test -f "$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION/source.properties" { + echo "ANDROID_NDK_VERSION=$ANDROID_NDK_VERSION" echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION" echo "ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION" echo "NDK_HOME=$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION" diff --git a/apps/weblibre/android/build.gradle b/apps/weblibre/android/build.gradle index 2841dd67..a2020700 100644 --- a/apps/weblibre/android/build.gradle +++ b/apps/weblibre/android/build.gradle @@ -2,7 +2,7 @@ ext { compileSdkVersion = 36 targetSdkVersion = 36 - ndkVersion = "28.2.13676358" + ndkVersion = providers.gradleProperty("weblibre.ndkVersion").get() } buildscript { diff --git a/apps/weblibre/android/gradle.properties b/apps/weblibre/android/gradle.properties index 1551eb08..efb319f6 100644 --- a/apps/weblibre/android/gradle.properties +++ b/apps/weblibre/android/gradle.properties @@ -1,4 +1,5 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError +weblibre.ndkVersion=28.2.13676358 android.useAndroidX=true android.enableJetifier=true # This builtInKotlin flag was added automatically by Flutter migrator diff --git a/native/go_mobile_runtime/README.md b/native/go_mobile_runtime/README.md index df167678..974824d4 100644 --- a/native/go_mobile_runtime/README.md +++ b/native/go_mobile_runtime/README.md @@ -39,6 +39,7 @@ The output AAR is written to `native/go_mobile_runtime/build/weblibre-go.aar`. GitHub release builds clone the pinned sources from `pins.env` and run the same Melos command before building the Flutter APK/AAB artifacts. The app Gradle -build and CI native runtime build both use Android NDK r28c (`28.2.13676358`), -matching Flutter 3.44's default NDK. This is new enough for the `cronet-go` -Android arm64 archives linked by sing-box's naive outbound path. +build and CI native runtime build both read `weblibre.ndkVersion` from +`apps/weblibre/android/gradle.properties`; it is currently Android NDK r28c +(`28.2.13676358`), matching Flutter 3.44's default NDK. This is new enough for +the `cronet-go` Android arm64 archives linked by sing-box's naive outbound path. diff --git a/native/go_mobile_runtime/scripts/build-android.sh b/native/go_mobile_runtime/scripts/build-android.sh index f29f6ae1..b9027fcb 100755 --- a/native/go_mobile_runtime/scripts/build-android.sh +++ b/native/go_mobile_runtime/scripts/build-android.sh @@ -9,6 +9,11 @@ REPO_ROOT="$(cd "$RUNTIME_DIR/../.." && pwd -P)" # shellcheck source=../pins.env source "$RUNTIME_DIR/pins.env" +GRADLE_PROPERTIES="$REPO_ROOT/apps/weblibre/android/gradle.properties" +DEFAULT_ANDROID_NDK_VERSION="$( + sed -n 's/^weblibre\.ndkVersion[[:space:]]*=[[:space:]]*//p' "$GRADLE_PROPERTIES" +)" + DEFAULT_SING_BOX_SOURCE="$(cd "$REPO_ROOT/.." && pwd -P)/sing-box" DEFAULT_IPTPROXY_SOURCE="$(cd "$REPO_ROOT/.." && pwd -P)/IPtProxy" @@ -18,7 +23,7 @@ DNSTT_SOURCE="${DNSTT_SOURCE:-$IPTPROXY_SOURCE/dnstt}" OUTPUT_AAR="${OUTPUT_AAR:-$RUNTIME_DIR/build/weblibre-go.aar}" TARGET="${TARGET:-android}" ANDROID_API="${ANDROID_API:-24}" -ANDROID_NDK_VERSION="${ANDROID_NDK_VERSION:-28.2.13676358}" +ANDROID_NDK_VERSION="${ANDROID_NDK_VERSION:-$DEFAULT_ANDROID_NDK_VERSION}" INSTALL_GOMOBILE=1 ALLOW_DIRTY=0 DEBUG=0 @@ -193,6 +198,11 @@ if ! command -v go >/dev/null 2>&1; then exit 1 fi +if [[ -z "$ANDROID_NDK_VERSION" ]]; then + echo "Missing weblibre.ndkVersion in $GRADLE_PROPERTIES." >&2 + exit 1 +fi + if [[ -z "${ANDROID_HOME:-}" && -d "$HOME/Android/Sdk" ]]; then export ANDROID_HOME="$HOME/Android/Sdk" fi