Back to Skills

r8-analyzer

Analyzes Android build files and R8 keep rules to identify redundancies, broad package-wide rules, and rules that subsume library consumer keep rules. Use when developers want to optimize their app's size, remove redundant or overly broad keep rules, or troubleshoot Proguard configurations.

6,714stars397forksUpdated 8/13/2026

Security Assessment

Safe(93/100)
Security Score93/100

About r8-analyzer

R8 Analyzer is a Google-authored Android skill that inspects build configuration and R8/ProGuard keep rules to find redundancies, overly broad package-wide rules, and rules that subsume library consumer keep rules. It targets a concrete app-size problem: keep rules accumulate and become broader than necessary, defeating shrinking and optimization, and they are hard to audit by hand. The skill diagnoses configuration, evaluates keep-rule impact, and emits a strict Markdown report of findings without modifying any project files.

It begins with a setup check of build.gradle, build.gradle.kts, gradle.properties, and libs.versions.toml to read AGP and R8 versions and spot missing optimizations. It then selects one of three analysis paths by tool version: Path A runs a standalone Gradle task (analyzeReleaseR8Config) and converts the generated protobuf report to JSON via bundled Python scripts for quantitative scoring; Path B generates and analyzes proto data via the R8 configuration analyzer when AGP is older but R8 is recent; and Path C is a heuristic manual evaluation of proguard-rules.pro against bundled reference files when quantitative data cannot be produced. Reference material covers redundant library rules, a keep-rules impact hierarchy, a reflection guide, and Macrobenchmark validation using UI Automator.

It is aimed at Android developers optimizing app size and troubleshooting ProGuard/R8 configuration. The skill is explicitly read-only: it researches and suggests Remove or Refine actions but does not change files, and it constrains output to the defined report format only.

FAQ

Does this skill modify my project or keep rules?

No. It is explicitly research-and-suggest only; it does not modify files. It outputs a Markdown report recommending which rules to Remove or Refine.

What does it run on my machine?

Depending on tool versions it may run a standalone Gradle task (./gradlew :app:analyzeReleaseR8Config) and bundled Python scripts (convert_pb_to_json.py, analyze.py) that convert and analyze the generated report. These are read-only analysis steps.

What are the prerequisites?

Quantitative paths require Python and the protobuf package, and recent AGP (9.3.0+ for the standalone task) or R8 (9.3.7-dev+). If neither is available it falls back to a heuristic manual evaluation.

How does it decide which analysis path to use?

It reads AGP and R8 versions from the build files: AGP 9.3.0+ uses the standalone Gradle task (Path A), older AGP with R8 9.3.7-dev+ uses quantitative generation (Path B), and otherwise it uses heuristic evaluation of proguard-rules.pro (Path C).

All Files

9 files
references/android/training/testing/other-components/ui-automator.md13.6 KB
View
references/REDUNDANT-RULES.md8.5 KB
View
SKILL.md4.4 KB
View
references/android/topic/performance/app-optimization/enable-app-optimization.md15.6 KB
View
references/REPORT_FORMAT.md2.0 KB
View
references/REFLECTION-GUIDE.md4.2 KB
View
references/CONFIGURATION-ANALYZER.md16.9 KB
View
references/CONFIGURATION.md1.5 KB
View
references/KEEP-RULES-IMPACT-HIERARCHY.md3.1 KB
View

Install r8-analyzer

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

android/skills