From c30a49e8415a7adaa680d1d6a788d22e08e8809b Mon Sep 17 00:00:00 2001 From: Jacob Hagstedt Date: Sun, 18 Oct 2026 21:32:15 +0200 Subject: [PATCH] Android: R8 shrinking, optimisation and resource shrinking for the release build isMinifyEnabled and isShrinkResources on the release build type with proguard-android-optimize.txt and an app proguard-rules.pro that adds no rules: the libraries' consumer rules cover kotlinx.serialization, Room 3, Hilt, Ktor, WorkManager (worker class names kept) and Firebase. Debug is unchanged. Signed release APK 43 356 272 -> 11 019 453 bytes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B --- android/app/build.gradle.kts | 5 +++++ android/app/proguard-rules.pro | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 android/app/proguard-rules.pro diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index fff7ac8..7293162 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -48,6 +48,11 @@ android { } release { if (releaseStoreFile != null) signingConfig = signingConfigs.getByName("release") + // SPEC §10.6: R8 shrinks, optimises and obfuscates the release APK; the libraries' consumer rules plus + // proguard-rules.pro. publish-apk.sh keeps build/outputs/mapping/release/mapping.txt next to the APK. + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } sourceSets { diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..ef43999 --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,3 @@ +# R8 rules for the release build of :app (SPEC §10.6). The libraries in use (kotlinx.serialization, Room 3, Hilt, +# Ktor, OkHttp, WorkManager, Firebase messaging, Coil) ship their own consumer rules; add a rule here only for a +# failure that was seen and with the reason beside it.