From 5b6f826fe661fb17989d45d7669f1032a2b50fc9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 15:22:40 +0000 Subject: [PATCH] Shrink the Android app with R8 Google Play warns that the app is not optimized. Turn on R8 and resource shrinking for release builds; Capacitor's consumer rules keep the plugin classes the bridge finds by reflection. Keep line numbers so the crash reports in Play stay readable with the mapping file from the bundle. Note why the portrait lock stays, which Play also warns about. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WABuqaLUF7uP6mJEEswTJp --- app/android/app/build.gradle | 8 ++++++-- app/android/app/proguard-rules.pro | 4 ++-- app/android/app/src/main/AndroidManifest.xml | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/android/app/build.gradle b/app/android/app/build.gradle index fd6c55f..8830954 100644 --- a/app/android/app/build.gradle +++ b/app/android/app/build.gradle @@ -24,9 +24,13 @@ android { applicationIdSuffix ".test" versionNameSuffix "-test" } + // R8 shrinks and optimizes the native part (Google Play asks for it). Capacitor's own rules + // keep every plugin class, which the bridge finds by reflection. The mapping file goes into + // the app bundle, so Play shows crash reports with the real class and method names. release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } // On Codemagic the upload key comes in through these variables (codemagic.yaml); without them, diff --git a/app/android/app/proguard-rules.pro b/app/android/app/proguard-rules.pro index f1b4245..f31e3fe 100644 --- a/app/android/app/proguard-rules.pro +++ b/app/android/app/proguard-rules.pro @@ -14,8 +14,8 @@ # Uncomment this to preserve the line number information for # debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile +-renamesourcefileattribute SourceFile diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml index 16bf6d2..c7bdf5e 100644 --- a/app/android/app/src/main/AndroidManifest.xml +++ b/app/android/app/src/main/AndroidManifest.xml @@ -13,6 +13,9 @@ +