Pular para o conteúdo
Skillpedia
Apps de celular10 mil · #11927

r8-analyzer

O que ela faz

Esta skill verifica arquivos de build Android e regras keep do R8 em busca de duplicatas e regras amplas demais. Ajuda a reduzir o tamanho do app e a corrigir configurações confusas de ProGuard. É para desenvolvedores Android que gerenciam a redução e a otimização do app.

Quando usar

  • ✓Quando você quer deixar o seu app Android menor limpando as regras keep do R8.
  • ✓Quando sua configuração de ProGuard ou R8 é difícil de entender e você quer uma revisão.
  • ✓Quando você quer verificar se um Android Gradle Plugin mais antigo deve migrar para uma configuração mais nova de otimização.

Link da skill

https://github.com/android/skills/blob/main/performance/r8-analyzer/SKILL.md

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/android/skills/blob/main/performance/r8-analyzer/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Revise as minhas regras keep do R8 e me diga quais são redundantes ou amplas demais.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A skill verifica os arquivos de build quanto à versão do Android Gradle Plugin e às configurações do R8. Depois segue um de dois caminhos de análise, dependendo da versão do plugin, para encontrar regras redundantes e amplas demais.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do GitHub.

Step 1. Setup and configuration check

  • Inspect build.gradle, build.gradle.kts, and gradle.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=false is removed from the gradle.properties file.

Step 2. Analysis path selection

  • Inspect build.gradle, build.gradle.kts, settings.gradle, settings.gradle.kts, gradle.properties, and libs.versions.toml to get the AGP and R8 versions. An R8 version pinned in settings.gradle(.kts) replaces the R8 bundled with AGP.

  • Find the app module (usually app) and a build variant with R8 enabled (usually release). 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 protobuf package 6.33.4 or later are mandatory (used by scripts/keep_radius_pb2.py). Install it with pip install "protobuf>=6.33.4"; versions lower than 6.33.4 fail on import with a VersionError or ImportError.
  • 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.py as python3 <skill_dir>/scripts/convert_pb_to_json.py with arguments <module>/build/reports/r8 and tmp/keepradius/keepruleradius.json. Wait for this command to finish.
  • Step 4: Analyze : You must explicitly run the analysis script scripts/analyze.py by executing python3 <skill_dir>/scripts/analyze.py tmp/keepradius/keepruleradius.json. This outputs tmp/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 protobuf package 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 in tmp/r8analysis/, convert it to tmp/r8analysis/keepruleradius.json, analyze the result, and revert the temporary settings.gradle(.kts) change.
  • Step 3: Analyze : Verify that the analysis outputs tmp/r8analysis/analysis_result.txt for 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.txt if using Path A, or tmp/r8analysis/analysis_result.txt if 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.
Perguntas frequentes

Ela corrige erros gerais de build do Gradle?

Não. Esses erros ficam fora desta skill, que foca em tamanho do app e regras keep.

Qual versão do plugin ela espera?

Para as versões 9.3.0 e mais novas, usa uma tarefa independente. Para versões anteriores, usa um caminho de análise medido.

Ela verifica a configuração do modo full?

Sim. Verifica se a antiga flag do modo full foi removida do gradle.properties.

Detalhes

Descrição original do autor

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

Popularidade

Estrelas no GitHub
10 mil
Posição no ranking
#11927
Licença
Apache-2.0
Atualizada em
29/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas