r8-analyzer

Analyzes Android build files and R8 keep rules to identify redundant and overly broad rules.

Updated May 21, 2025
One-click install
npx skills add https://github.com/albertmartorell1975/MeteoMartoCompose --skill r8-analyzer-albertmartorell1975
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: r8-analyzer
Source: https://github.com/albertmartorell1975/MeteoMartoCompose/tree/main/.agents/skills/r8-analyzer
Command: npx skills add https://github.com/albertmartorell1975/MeteoMartoCompose --skill r8-analyzer-albertmartorell1975

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires protobuf, and includes references (resource) components.

What problem does it solve? Android apps often ship with redundant, overly broad, or outdated ProGuard/R8 keep rules that block code shrinking, obfuscation, and optimization, inflating app size and hurting performance. This Skill audits your build configuration and keep rules to pinpoint exactly which rules to remove or refine. ## Core Features & Use Cases - Quantitative analysis: For R8 9.3.7-dev and later, runs the R8 Configuration Analyzer to generate optimization, shrinking, and obfuscation scores plus per-rule impact metrics. - Heuristic evaluation: For older R8 versions, manually inspects proguard-rules.pro against known redundant library rules (Gson, Retrofit, Room, Coroutines, AndroidX) and ranks rules by optimization impact. - Structured report: Outputs a strict Markdown report covering configuration issues, global disable rules, optimization scores, keep rule evaluation, and subsumed rules. - Use Case: You inherit a legacy Android project with a 200-line proguard-rules.pro file. Run this Skill to discover that most rules are already bundled by modern libraries and receive a concrete remove/refine action list. ## Quick Start Analyze my Android project's R8 and ProGuard keep rules and tell me which ones to remove or refine to reduce app size.

Frequently Asked Questions about r8-analyzer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find redundant ProGuard keep rules in my Android project?▼

Inspect proguard-rules.pro and compare each rule against the consumer keep rules bundled in modern libraries like Gson 2.11+, Retrofit 2.9+, Room, and Kotlin Coroutines. Rules targeting androidx, kotlin, or kotlinx packages are typically redundant and can be deleted.

How do I measure the impact of R8 keep rules on app size?▼

Use the R8 Configuration Analyzer available from R8 9.3.7-dev by running a release build with the dumpkeepradiustodirectory system property. It generates a protobuf report that can be converted to JSON to compute optimization, shrinking, and obfuscation scores per rule.

Does R8 full mode need to be enabled manually?▼

R8 full mode is enabled by default from AGP 8.0 onward. You only need to ensure android.enableR8.fullMode=false is not present in gradle.properties; for pre-AGP 8.0 projects, explicitly set it to true.

Why are package-wide keep rules bad for R8 optimization?▼

Rules like -keep class com.example.** { *; } prevent shrinking, obfuscation, and optimization of every class and member in the package tree. They should be refined to target specific classes or members, or replaced with conditional rules like -keepclassmembers.

Can I keep Gson or Retrofit rules if my libraries are up to date?▼

No. Gson 2.11+ and Retrofit 2.9+ bundle their own consumer ProGuard rules that preserve annotated fields and HTTP interfaces automatically. Manual rules for these libraries are broader than needed and should be removed.