r8-analyzer

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

3|Updated Aug 4, 2024
One-click install
npx skills add https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform --skill r8-analyzer-kabindra-shrestha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: r8-analyzer
Source: https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform/tree/main/.agents/skills/performance/r8-analyzer
Command: npx skills add https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform --skill r8-analyzer-kabindra-shrestha

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Android apps often ship with redundant or overly broad ProGuard/R8 keep rules that block code shrinking, obfuscation, and optimization, inflating app size and slowing performance. This Skill audits your build configuration and keep rules to pinpoint exactly which rules prevent R8 from optimizing your code. ## Core Features & Use Cases - Quantitative analysis: For R8 9.3.7-dev or 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) and ranks rules by optimization impact. - Structured reporting: Produces a strict Markdown report covering configuration issues, global disable rules, keep rule evaluation, subsumed rules, and historical score comparison. - Use Case: A developer notices their release APK is larger than expected. They run this Skill, which identifies a package-wide -keep class com.example.** { *; } rule blocking 30% of the codebase from optimization and recommends a surgical replacement. ## Quick Start Analyze my Android project's R8 and ProGuard configuration and tell me which keep rules are hurting my 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 app?

Run an R8 keep rule analysis that compares your proguard-rules.pro against rules already bundled by libraries like Gson, Retrofit, Room, and Kotlin Coroutines. Rules targeting androidx, kotlin, or kotlinx packages are typically redundant and can be deleted.

How to measure the impact of R8 keep rules on app size?

Use the R8 Configuration Analyzer available in R8 9.3.7-dev or later. Run a release build with the dumpkeepradiustodirectory system property, convert the protobuf output to JSON, and compute optimization, shrinking, and obfuscation scores per rule.

Does R8 full mode need to be enabled manually?

For AGP 8.0 and later, R8 full mode is enabled by default, so you only need to ensure android.enableR8.fullMode=false is not present in gradle.properties. For pre-AGP 8.0, explicitly set android.enableR8.fullMode=true.

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

Rules like -keep class com.example.** { *; } prevent all optimization, shrinking, and obfuscation for every class in the package and subpackages. They should be refined to target specific classes or members needed for reflection or serialization.

Can I use this analysis with older versions of R8?

Yes, but only heuristic evaluation is available for R8 versions below 9.3.7-dev. The analysis manually inspects proguard-rules.pro against known redundant rules and an impact hierarchy instead of generating quantitative scores.