r8-analyzer
Was er macht
Dieser Skill prüft Android-Build-Dateien und R8-Keep-Regeln auf Doppelungen und Regeln, die zu weit gefasst sind. Er hilft, die App-Größe zu verringern und unübersichtliche ProGuard-Einstellungen zu korrigieren. Er ist für Android-Entwickler gedacht, die das Verkleinern und Optimieren der App verwalten.
Wann du ihn nutzt
- ✓Wenn du deine Android-App kleiner machen willst, indem du die R8-Keep-Regeln aufräumst.
- ✓Wenn deine ProGuard- oder R8-Konfiguration schwer zu verstehen ist und du sie prüfen lassen willst.
- ✓Wenn du prüfen willst, ob ein älteres Android Gradle Plugin auf eine neuere Einrichtung für die App-Optimierung umsteigen sollte.
Link zum Skill
https://github.com/android/skills/blob/main/performance/r8-analyzer/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Prüfe meine R8-Keep-Regeln und sag mir, welche überflüssig oder zu weit gefasst sind.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Skill prüft deine Build-Dateien auf die Version des Android Gradle Plugins und auf die R8-Einstellungen. Je nach Plugin-Version folgt er einem von zwei Analysepfaden, um überflüssige und zu weit gefasste Regeln zu finden.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Step 1. Setup and configuration check
- Inspect
build.gradle,build.gradle.kts, andgradle.properties. - Use references/CONFIGURATION.md to identify missing optimizations.
- AGP : If the version is lower than 9.3, suggest migration to 9.3 for the simplified
optimization {}DSL and the Configuration Analyzer task. - Full mode : Verify
android.enableR8.fullMode=falseis removed from thegradle.propertiesfile.
Step 2. Analysis path selection
Inspect
build.gradle,build.gradle.kts,settings.gradle,settings.gradle.kts,gradle.properties, andlibs.versions.tomlto get the AGP and R8 versions. An R8 version pinned insettings.gradle(.kts)replaces the R8 bundled with AGP.Find the app module (usually
app) and a build variant with R8 enabled (usuallyrelease). The following commands use them as<module>and<Variant>, for example:app:minifyReleaseWithR8.The helper scripts are in this skill's
scripts/directory. In the following commands,<skill_dir>is this skill's directory. Run every command from the project root.If AGP >= 9.3.0 : Proceed to Path A (Standalone Task).
If AGP < 9.3.0 : Proceed to Path B (Quantitative).
Path A: Standalone Gradle task (AGP >= 9.3.0)
- Step 1: Check requirements : Python and the
protobufpackage 6.33.4 or later are mandatory (used byscripts/keep_radius_pb2.py). Install it withpip install "protobuf>=6.33.4"; versions lower than 6.33.4 fail on import with aVersionErrororImportError. - Step 2: Run standalone task on R8-enabled build : For the module and variant you found during path selection, run
./gradlew :<module>:analyze<Variant>R8Config(for example,./gradlew :app:analyzeReleaseR8Config). It generates the report in<module>/build/reports/r8/(for example,app/build/reports/r8/r8-config-analyzer-release.pb). You must wait for this command to finish before proceeding. - Step 3: Convert to JSON : You must explicitly run the conversion script
scripts/convert_pb_to_json.pyaspython3 <skill_dir>/scripts/convert_pb_to_json.pywith arguments<module>/build/reports/r8andtmp/keepradius/keepruleradius.json. Wait for this command to finish. - Step 4: Analyze : You must explicitly run the analysis script
scripts/analyze.pyby executingpython3 <skill_dir>/scripts/analyze.py tmp/keepradius/keepruleradius.json. This outputstmp/keepradius/analysis_result.txt. Wait for this command to finish.
Path B: Invoke R8 release build (AGP < 9.3.0)
- Step 1: Check requirements : Python and the
protobufpackage 6.33.4 or later are mandatory:pip install "protobuf>=6.33.4". - Step 2: Generate and analyze : You must run the shell commands described in references/FULL_BUILD_CONFIG_ANALYZER.md to temporarily update the R8 version in
settings.gradle(.kts)to 9.4.34 or later (so R8 generates the report), generate the proto report intmp/r8analysis/, convert it totmp/r8analysis/keepruleradius.json, analyze the result, and revert the temporarysettings.gradle(.kts)change. - Step 3: Analyze : Verify that the analysis outputs
tmp/r8analysis/analysis_result.txtfor scores and rule impact metrics.
Step 3. Report generation
- Format : Follow references/REPORT_FORMAT.md strictly.
- Redundant rules : Check keep rules against references/INSPECT-RULES.md. If a keep rule matches a pattern in references/INSPECT-RULES.md, include the guidance and remediation from that reference alongside the impact metrics.
- Input : Extract metrics (Scores, Impacts, Example Classes, rule origins) directly from the generated file
tmp/keepradius/analysis_result.txtif using Path A, ortmp/r8analysis/analysis_result.txtif using Path B. - Output : Short progress updates are fine while Gradle runs; the final message is the report only. Output only the raw Markdown report in the chat. Do not output conversational filler (for example, "Here is your report..."). Do not provide recommendations, next steps, or any other text outside of the sections defined in references/REPORT_FORMAT.md.
Häufige Fragen
Behebt er allgemeine Gradle-Build-Fehler?
Nein. Die gehören nicht zu diesem Skill, der sich auf App-Größe und Keep-Regeln konzentriert.
Welche Plugin-Version erwartet er?
Ab Version 9.3.0 nutzt er eine eigenständige Aufgabe. Für ältere Versionen nutzt er einen gemessenen Analysepfad.
Prüft er den Vollmodus?
Ja. Er prüft, dass das alte Flag für den Vollmodus aus gradle.properties entfernt ist.
Details
Originalbeschreibung des Autors
Analyzes Android build files and R8 keep rules to identify redundancies, broad package-wide rules, and rules that subsume library consumer keep rules. Use this skill when developers want to optimize their Android app's size, remove redundant or overly broad keep rules, or troubleshoot ProGuard configurations. Don't use for general Gradle build errors, Compose UI performance, or runtime CPU profiling.
repo: android/skills
Beliebtheit
- GitHub-Sterne
- 10k
- Platz im Ranking
- #11927
- Lizenz
- Apache-2.0
- Aktualisiert
- 29.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
agp-9-upgrade
10kHilft deinem Agenten, eine Android-App auf Android Gradle Plugin 9 zu aktualisieren und die Breaking Changes abzuarbeiten. Nicht für Multiplattform-Projekte.
camerax
10kHilft deinem Agenten, Kamerafunktionen für Android mit CameraX zu bauen, einschließlich Videoaufnahme, Hardwaresteuerung, ML Kit und Media3-Effekten.
android-for-cars-parked-apps
10kHilft deinem Agenten, eine Android-Video-, Spiele- oder Browser-App so anzupassen, dass sie als geparkte App in Android Auto und Android Automotive läuft.
appfunctions
10kHilft deinem Agenten, in einer Android-App wichtige Abläufe zu finden und sie als AppFunctions bereitzustellen, die KI-Agenten und Sprachbefehle ausführen können.
Ähnliche Skills
android-clean-architecture
280kLässt deinen Agenten Android-Projekte effizient strukturieren. Der Code wird so organisiert, dass Wartung und neue Features leichter werden.
compose-multiplatform-patterns
280kHilft deinem Agenten, Compose Multiplatform und Jetpack Compose Patterns in KMP-Projekten einzusetzen. Abgedeckt sind State, Navigation, Theming und Performance.
dart-flutter-patterns
280kLässt deinen Agenten Code für Dart- und Flutter-Apps schreiben. Er nutzt moderne Patterns für robuste und gut wartbare Apps.