← ClaudeAtlas

android-obfuscation-r8listed

R8 obfuscation and code shrinking for Android - R8 vs ProGuard, proguard-rules.pro patterns, keep rules for serialization (Gson/Moshi/kotlinx.serialization) and reflection-heavy libraries (Retrofit, Room, Koin, Firebase), mapping file management for crash deobfuscation, testing the release build, and debugging R8 issues with -printusage and -whyareyoukeeping. Use this skill whenever configuring shrinking/obfuscation, diagnosing release-only crashes, writing keep rules for a new library, or preparing a release build. Trigger on phrases like "ProGuard", "R8", "obfuscation", "minification", "keep rules", "proguard-rules", "release build crash", "mapping file", "shrinking", "minifyEnabled", or "-keep".
lenorebreakneck630/claude-zero-to-hero-android-KMP · ★ 1 · AI & Automation · score 64
Install: claude install-skill lenorebreakneck630/claude-zero-to-hero-android-KMP
# Android R8 Obfuscation & Code Shrinking ## Overview R8 is the default shrinker, obfuscator, and optimizer for Android release builds. It replaces ProGuard and is enabled automatically when `minifyEnabled = true`. R8 does three things: **shrinking** (removes unused classes/methods/fields), **obfuscation** (renames to short names like `a.b.c`), and **optimization** (inlines methods, removes dead code branches). All three happen in a single pass. The most common mistake is shipping a release build without testing it — R8 regularly removes or renames things that are accessed only via reflection, breaking the app silently at runtime. --- ## R8 vs ProGuard | | R8 | ProGuard | |---|---|---| | Default in AGP | Yes (since AGP 3.4) | No | | Full mode | Yes (`r8.fullModeEnabled=true` in `gradle.properties`) | No | | Speed | ~2x faster | Slower | | Kotlin support | Native | Via keep rules | | Compose support | Native | Limited | | Use today | Always | Never — do not switch back | R8 full mode enables more aggressive shrinking (inlining of interfaces, more dead-code elimination). It is recommended for new projects and enabled by default in AGP 8+. ```properties # gradle.properties — enable full mode explicitly if not already default android.enableR8.fullMode=true ``` --- ## Enabling R8 ```kotlin // app/build.gradle.kts android { buildTypes { release { isMinifyEnabled = true // enables R8 shrinking + obfuscation isShrinkResources = tru