본문으로 건너뛰기
Skillpedia
모바일 앱10k · #11927

r8-analyzer

하는 일

이 스킬은 Android 빌드 파일과 R8 유지 규칙에서 중복이나 지나치게 넓은 규칙을 확인합니다. 앱 크기를 줄이고 복잡한 ProGuard 설정을 바로잡는 데 도움을 줍니다. 앱 축소와 최적화를 관리하는 Android 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓R8 유지 규칙을 정리해 Android 앱 크기를 줄이고 싶을 때.
  • ✓ProGuard나 R8 설정이 복잡해서 검토가 필요할 때.
  • ✓오래된 Android Gradle Plugin을 앱 최적화를 위해 더 새로운 설정으로 옮겨야 하는지 확인하고 싶을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/android/skills/blob/main/performance/r8-analyzer/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“내 R8 유지 규칙을 검토해서 중복되거나 지나치게 넓은 규칙이 무엇인지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 빌드 파일에서 Android Gradle Plugin 버전과 R8 설정을 확인합니다. 그다음 플러그인 버전에 따라 두 가지 분석 경로 중 하나를 따라 중복과 지나치게 넓은 규칙을 찾습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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.
자주 묻는 질문

일반적인 Gradle 빌드 오류도 고치나요?

아니요. 앱 크기와 유지 규칙에 초점을 맞추므로 그런 오류는 이 스킬 범위 밖입니다.

어떤 플러그인 버전을 기대하나요?

9.3.0 이상 버전에는 독립 작업을 사용하고, 이전 버전에는 측정 기반 분석 경로를 사용합니다.

전체 모드(full mode) 설정도 확인하나요?

네. 오래된 전체 모드 플래그가 gradle.properties에서 제거되었는지 확인합니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
10k
순위
#11927
라이선스
Apache-2.0
업데이트
2026. 10. 29.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬