ci(gitea): strip native libs with a native llvm-strip so APKs are not 15x too big
Build Android APK / Build Release APKs (push) Successful in 16m29s

AGP's stripReleaseDebugSymbols failed silently on the ARM64 runner because
the NDK r28 x86_64 llvm-strip cannot load libz.so.1 under QEMU, leaving the
unstripped libflutter.so (165 MB per ABI) in the APKs (universal 521 MB).

Pre-install the NDK version Flutter expects via sdkmanager and replace its
llvm-strip/llvm-objcopy with Ubuntu's native arm64 LLVM tools, which strip
any ELF target without emulation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 00:18:48 +02:00
co-authored by Claude Opus 5
parent 744def72fd
commit 1eb089f6b5
+16 -1
View File
@@ -64,7 +64,7 @@ jobs:
# On Linux ARM64, Flutter engine and Android AAPT2 need x86_64 emulation via QEMU. # On Linux ARM64, Flutter engine and Android AAPT2 need x86_64 emulation via QEMU.
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
echo "Setting up ARM64 Flutter environment & QEMU binfmt emulation..." echo "Setting up ARM64 Flutter environment & QEMU binfmt emulation..."
apt-get update -qq && apt-get install -y -qq qemu-user-static binfmt-support libc6-amd64-cross libstdc++6-amd64-cross gcc apt-get update -qq && apt-get install -y -qq qemu-user-static binfmt-support libc6-amd64-cross libstdc++6-amd64-cross gcc llvm
# Setup x86_64 dynamic libraries & prefix for QEMU emulation # Setup x86_64 dynamic libraries & prefix for QEMU emulation
mkdir -p /etc/qemu-binfmt mkdir -p /etc/qemu-binfmt
@@ -111,6 +111,21 @@ jobs:
echo "Configured gen_snapshot wrapper for $(basename "$dir")" echo "Configured gen_snapshot wrapper for $(basename "$dir")"
fi fi
done done
# AGP strips libflutter.so/libapp.so with the NDK's llvm-strip; unstripped they
# are ~15x larger (165 MB instead of 12 MB per ABI). The NDK's x86_64 llvm-strip
# cannot run under QEMU (needs libz.so.1 etc. in the cross sysroot), so install
# the NDK Flutter expects up front and swap in Ubuntu's native arm64 llvm-strip.
NDK_VERSION="$(sed -nE 's/.*ndkVersion: String = "([^"]+)".*/\1/p' "${FLUTTER_ROOT:-/sdks/flutter}/packages/flutter_tools/gradle/src/main/kotlin/FlutterExtension.kt")"
[ -n "$NDK_VERSION" ] || { echo "::error::Could not determine Flutter's NDK version"; exit 1; }
echo "Installing NDK $NDK_VERSION ..."
yes | sdkmanager --install "ndk;${NDK_VERSION}" > /dev/null
NDK_BIN="${ANDROID_HOME:-/opt/android-sdk-linux}/ndk/${NDK_VERSION}/toolchains/llvm/prebuilt/linux-x86_64/bin"
for tool in llvm-strip llvm-objcopy; do
mv "$NDK_BIN/$tool" "$NDK_BIN/$tool.x86_64"
ln -s "$(command -v "$tool")" "$NDK_BIN/$tool"
done
"$NDK_BIN/llvm-strip" --version | head -n 2
fi fi
- name: Checkout Repository - name: Checkout Repository