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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
This commit is contained in:
2026-10-18 21:32:15 +02:00
parent a0c25b0db5
commit c30a49e841
2 changed files with 8 additions and 0 deletions
+5
View File
@@ -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 {
+3
View File
@@ -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.