android-obfuscation-r8listed
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