Created
November 28, 2025 07:55
-
-
Save minademian/71a5a3d0243496ce6a2a49956c01e4cd to your computer and use it in GitHub Desktop.
Verify Android AAB Bundles Before Publishing to Google Play Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # verify_aab_release.sh | |
| # Pre-publish hook for Android Release AABs with 16KB pagesize and arm64-only ABI support | |
| # Usage: ./verify_aab_release.sh | |
| set -euo pipefail | |
| ANDROID_DIR="./android" | |
| BUILD_DIR="$ANDROID_DIR/app/build/outputs/bundle/release" | |
| AAB_FILE="$BUILD_DIR/app-release.aab" | |
| NDK_HOME="$ANDROID_HOME/ndk/26.1.10909125" | |
| READELF_BIN="$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-readelf" | |
| echo $READELF_BIN | |
| if [[ ! -x "$READELF_BIN" ]]; then | |
| echo "[ERROR] llvm-readelf not found. Please install LLVM via Homebrew: brew install llvm" | |
| exit 1 | |
| fi | |
| echo "[hook] Starting pre-publish verification..." | |
| echo "[hook] Checking ABI content in AAB..." | |
| unzip -l "$AAB_FILE" | grep "lib/" > /tmp/aab_libs.txt | |
| if grep -qv "lib/arm64-v8a/" /tmp/aab_libs.txt; then | |
| echo "[ERROR] Found non-arm64-v8a ABIs in AAB!" | |
| grep -v "lib/arm64-v8a/" /tmp/aab_libs.txt | |
| exit 1 | |
| else | |
| echo "[hook] ✅ Only arm64-v8a found." | |
| fi | |
| echo "[hook] Verifying ELF max page size (16384)..." | |
| TMP_EXTRACT="/tmp/aab_extract" | |
| rm -rf "$TMP_EXTRACT" | |
| mkdir -p "$TMP_EXTRACT" | |
| echo "[hook] Extracting AAB contents to $TMP_EXTRACT..." | |
| unzip -q "$AAB_FILE" -d "$TMP_EXTRACT" | |
| SO_FILES=() | |
| while IFS= read -r line; do | |
| SO_FILES+=("$line") | |
| done < <(find "$TMP_EXTRACT" -path "*/lib/arm64-v8a/*.so") | |
| echo "[hook] Found ${#SO_FILES[@]} .so files to check." | |
| FAILED=0 | |
| for f in "${SO_FILES[@]}"; do | |
| ALIGN_VALUES=$("$READELF_BIN" -l "$f" \ | |
| | grep 'LOAD' \ | |
| | awk '{print $NF}') | |
| if [[ -z "$ALIGN_VALUES" ]]; then | |
| echo "[ERROR] Could not parse LOAD align for $f" | |
| FAILED=1 | |
| continue | |
| fi | |
| for ALIGN in $ALIGN_VALUES; do | |
| ALIGN_DEC=$((ALIGN)) | |
| if [[ "$ALIGN_DEC" != 16384 ]]; then | |
| echo "[ERROR] $f has LOAD Align=$ALIGN (=$ALIGN_DEC) expected 16384" | |
| FAILED=1 | |
| else | |
| echo "[hook] ✅ $f has correct MaxPageSize=16384" | |
| fi | |
| done | |
| done | |
| if [[ $FAILED -eq 0 ]]; then | |
| echo "[hook] ✅ All .so files have MaxPageSize=16384" | |
| else | |
| exit 1 | |
| fi | |
| echo "[hook] Pre-publish verification passed." | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment