capacitor-android-dex-optimization
БесплатноБез исполняемых скриптовНе проверенGuides the agent through enabling R8 in a Capacitor Android app so that it meets the Google Play DEX code optimization requirement (at least 25% obfuscation…
от capawesome-team★ 56 звёзд на GitHubОб этом скилле
Capacitor Android: DEX Code Optimization
Enable R8 in a Capacitor Android app and add the keep rules a Capacitor app needs so that the release build passes the Google Play DEX code optimization requirement without crashing at startup.
The Android project that npx cap add android generates sets minifyEnabled false, so R8 never runs and Google Play measures close to 0% obfuscation, optimization and shrinking. From February 2027, Google Play requires at least 25% in each category for apps with more than 10 MB of DEX code. Play reads the numbers from the r8.json file inside the app bundle for apps built with AGP 8.10 or newer.
Prerequisites
| Requirement | Version |
|---|---|
| Capacitor | 6+ |
| Android Gradle Plugin | 8.0+ (8.10+ for the r8.json check in Step 6) |
| JDK | 17 for Capacitor 6 and 7, 21 for Capacitor 8 |
adb |
installed, with a device or emulator connected for Step 5 |
The project must be a Capacitor app (not a plugin) with an existing android/ directory.
Agent Behavior
- Inspect before editing. Read the current Gradle and ProGuard configuration first (Step 1). Never overwrite existing rules in
android/app/proguard-rules.pro; append to them. - Keep rules narrow. Never add
-keep class com.getcapacitor.** { *; }or-dontobfuscate. Broad rules block the optimization that Google Play measures.@capacitor/androidalready ships consumer rules for plugin classes and their annotated methods. - Only release builds run R8. Debug builds never show whether the rules are complete. Every verification step uses a signed release build.
- Read
missing_rules.txtbefore pasting it. A-dontwarnrule is correct only for a class a plugin probes for at runtime (Step 4).
Procedures
Step 1: Analyze the Project
Verify the project is a Capacitor app:
package.jsonlists@capacitor/androidindependenciesand theandroid/directory exists. Ifandroid/is missing, abort and inform the user.Read the
@capacitor/coreversion frompackage.json. Record the major version.Read the AGP version from
android/build.gradle:classpath 'com.android.tools.build:gradle:8.13.2'If the major version is below 8, abort and direct the user to the
capacitor-app-upgradesskill first. Record whether the version is 8.10 or newer (this decides whether Step 6 applies).Read the
releasebuild type inandroid/app/build.gradle. Record the values ofminifyEnabled,shrinkResources(if present) and theproguardFilesline.Read
android/app/proguard-rules.proand record every existing rule.Read
android/gradle.propertiesand record whetherandroid.enableR8.fullModeis set. If it is set tofalse, inform the user that the keep rule in Step 3 makes this setting unnecessary and offer to remove it, because full mode produces higher optimization numbers.Inventory the installed Capacitor plugins from
package.jsondependencies. Match these prefixes:@capacitor/*@capawesome/*and@capawesome-team/*@capacitor-community/*@capacitor-firebase/*@capacitor-mlkit/*@revenuecat/*- Any other package with
"capacitor"in itspackage.jsonkeywordsarray
Record each plugin's package name. Step 3 uses this list.
Step 2: Enable R8
In android/app/build.gradle, update the release build type. Replace minifyEnabled false with minifyEnabled true and replace proguard-android.txt with proguard-android-optimize.txt:
android {
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
proguard-android.txt contains -dontoptimize, which blocks most of what R8 could do, and AGP 9 no longer accepts that file by default. Do not add shrinkResources true. The Play metrics measure DEX code, and resource shrinking breaks resources that are referenced by name from JavaScript or capacitor.config.ts (for example the smallIcon of the Push Notifications plugin).
Step 3: Add Keep Rules
If the Capacitor version recorded in Step 1 is below 8.6.0, append the Capacitor annotation rule to
android/app/proguard-rules.pro. Skip this if the file already contains the exact rule or if the app is on Capacitor 8.6.0 or newer, which ships the rule in its consumer rules:+# Capacitor annotations: required below Capacitor 8.6.0 in R8 full mode (ionic-team/capacitor#8589) +-keep @interface com.getcapacitor.** { *; }R8 full mode (the default since AGP 8.0) strips annotations from classes that are not explicitly kept. Before Capacitor 8.6.0,
@capacitor/androidkept the classes annotated with@CapacitorPluginbut not
Установить capacitor-android-dex-optimization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл capacitor-android-dex-optimization?
Guides the agent through enabling R8 in a Capacitor Android app so that it meets the Google Play DEX code optimization requirement (at least 25% obfuscation, optimization and shrinking from February 2027 for apps with more than 10 MB of DEX code). Covers `minifyEnabled true` with `proguard-android-optimize.txt` in `android/app/build.gradle`, the `-keep @interface com.getcapacitor.** { *; }` rule that prevents the startup crash in R8 full mode, per-plugin keep rules, resolving R8 'Missing class' build errors via `missing_rules.txt`, building a signed release APK with the debug keystore, and verifying with logcat, `mapping.txt` and the `r8.json` file inside the app bundle. Use when Play Console reports a DEX code optimization finding, when a Capacitor app crashes on startup after enabling `minifyEnabled`, or when R8 fails the release build. Do not use for iOS, resource shrinking, Capacitor plugin projects, Capacitor version upgrades, or non-Capacitor mobile frameworks.
Как установить скилл capacitor-android-dex-optimization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл capacitor-android-dex-optimization запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic