From 75d5bd3e79f025303bd049da02edb0c7280b7add Mon Sep 17 00:00:00 2001 From: Dennis Falling Date: Fri, 10 Jul 2026 23:42:16 +0100 Subject: [PATCH] Shrink release APK and fix broken release bundling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The release JS bundle could not build at all: graphql v17 ships .mjs using `export * as Kind from ...`, which the RN Babel preset doesn't transform. CI only runs assembleDebug (Metro serves JS live, no bundling), so it never surfaced — but any v* release tag would have failed. Add the export-namespace-from Babel plugin to fix it. Also cut the shipped APK ~68% (110 MB -> 35 MB) with no product-code changes: ship arm64-v8a only (every target device is 64-bit ARM; the other three ABIs are dead weight and also 4x the build time), and enable R8 + resource shrinking on release builds. Co-Authored-By: Claude Opus 4.8 (1M context) --- android/app/build.gradle | 3 ++- android/gradle.properties | 7 ++++++- babel.config.js | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 502190d..f602ffc 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -57,7 +57,7 @@ react { /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ -def enableProguardInReleaseBuilds = false +def enableProguardInReleaseBuilds = true /** * The preferred build flavor of JavaScriptCore (JSC) @@ -114,6 +114,7 @@ android { def hasReleaseKeystore = System.getenv('RELEASE_STORE_FILE') || project.findProperty('RELEASE_STORE_FILE') signingConfig hasReleaseKeystore ? signingConfigs.release : signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds + shrinkResources enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } diff --git a/android/gradle.properties b/android/gradle.properties index 9afe615..4e0e8da 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -25,7 +25,12 @@ android.useAndroidX=true # Use this property to specify which architecture you want to build. # You can also override it from the CLI using # ./gradlew -PreactNativeArchitectures=x86_64 -reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 +# Ship arm64-v8a only. Every real target device (GrapheneOS/Pixels and modern +# stock Android) is 64-bit ARM; x86/x86_64 are emulator-only and armeabi-v7a is +# pre-2017 32-bit. This controls both which ABIs are compiled and which ship, so +# it also cuts build time ~4x. To run a debug build on an x86_64 emulator, +# override per-invocation: ./gradlew ... -PreactNativeArchitectures=x86_64 +reactNativeArchitectures=arm64-v8a # Use this property to enable support to the new architecture. # This will allow you to use TurboModules and the Fabric render in diff --git a/babel.config.js b/babel.config.js index f7b3da3..5dabc66 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,7 @@ module.exports = { presets: ['module:@react-native/babel-preset'], + // graphql v17 ships .mjs using `export * as Kind from ...` (export-namespace-from). + // The RN preset doesn't transform this, so release bundling fails without it. + // Debug builds serve JS from Metro and skip bundling, so CI never hit this. + plugins: ['@babel/plugin-transform-export-namespace-from'], };