configuring-r8-for-compose
Installation
SKILL.md
Configuring R8 for Compose — Trust Consumer Rules, Avoid Blanket Keeps
R8 is the only supported shrinker — ProGuard is deprecated. Compose ships consumer ProGuard rules, so most apps need no Compose-specific keep rules. The big modern wins come from R8 full mode (default since AGP 8.0): lambda grouping, sourceInformation() stripping, constant-folding of composable args, and ComposerImpl devirtualization. This skill teaches Claude to set R8 up minimally and refuse over-broad keeps that defeat those wins.
When to use this skill
- Setting up a new Compose app's release variant for the first time.
- A PR adds
-keep class androidx.compose.** { *; }or any other Compose-wide keep — push back and apply this skill. - A release build crashes after enabling minification — the cause is almost always a missing keep on a reflective consumer, not on Compose itself.
- APK size review surfaces a large
classes.dexand the developer wants to know why. - The first time
isMinifyEnabled = trueis being flipped on, before any release benchmark is run. - Cross-link from
../../measurement/testing-compose-in-release-mode/SKILL.mdwhenever release measurement is being set up.
When NOT to use this skill
- The app is not yet ready to ship a release variant — wait until perf and crash budgets are in scope.
- The developer is debugging a code-level bug (logic error, race, wrong state). R8 issues manifest as
ClassNotFoundException,NoSuchMethodError, or empty reflection results — not behavioral bugs. - The release variant has been measured and is fine — do not pre-emptively add keep rules.
- The perf concern is recomposition, layout phase, or stability — see the relevant
stability/orrecomposition/skills.