# /r8-analyzer: Find redundant and overly broad R8 keep rules

Source: https://trendhub.net/skills/android-skills/r8-analyzer
Skill folder: https://github.com/android/skills/tree/main/performance/r8-analyzer
Pack: Android Skills (https://trendhub.net/skills/android-skills)
Works with: Android CLI (detected agents), Claude Code, Codex

r8-analyzer reviews how an Android app configures R8 and which keep rules are hurting shrinking. Depending on the AGP version it either runs the built-in configuration analyzer task or a temporary newer R8 build, converts the report with bundled Python scripts, and returns a strict Markdown report on broad, redundant or subsumed rules. It does not change project code.

## When to use it

- Your APK or AAB is larger than expected and you suspect keep rules.
- You inherited a ProGuard file full of package-wide keep rules.
- You want to know whether your app overrides library consumer rules.

## How it works

1. **Check configuration**: The agent inspects Gradle files and gradle.properties for missing optimisations and suggests AGP 9.3 when the project is older.
2. **Choose a path**: On AGP 9.3 or later it runs the analyze R8 config Gradle task; on older versions it temporarily pins a newer R8 in settings to produce the report.
3. **Convert and analyse**: Bundled Python scripts, which need the protobuf package, turn the report into JSON and compute scores and rule impact.
4. **Report only**: The final reply is the Markdown report in the prescribed format, listing affected rules with their impact and remediation guidance.

## What it steers the agent away from

- Editing project files beyond the temporary, reverted R8 pin.
- Printing placeholder scores when data is missing.
- Padding the report with general R8 explanations or next-step chatter.

## What it can touch

It runs Gradle tasks and Python scripts, writes only under a tmp folder, and may temporarily edit settings.gradle after asking, reverting it afterwards.

## Pairs well with

- `/agp-9-upgrade`
- `/jetpack-compose-performance`

## Questions

### What do I need installed?

Python with protobuf 6.33.4 or later, plus an app module with an R8-enabled variant such as release.

### What if I refuse the settings change on older AGP?

The agent still reports rule-level and build file findings, but without scores, and says why.
