Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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/android already 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.txt before pasting it. A -dontwarn rule is correct only for a class a plugin probes for at runtime (Step 4).

Procedures

Step 1: Analyze the Project

  1. Verify the project is a Capacitor app: package.json lists @capacitor/android in dependencies and the android/ directory exists. If android/ is missing, abort and inform the user.

  2. Read the @capacitor/core version from package.json. Record the major version.

  3. 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-upgrades skill first. Record whether the version is 8.10 or newer (this decides whether Step 6 applies).

  4. Read the release build type in android/app/build.gradle. Record the values of minifyEnabled, shrinkResources (if present) and the proguardFiles line.

  5. Read android/app/proguard-rules.pro and record every existing rule.

  6. Read android/gradle.properties and record whether android.enableR8.fullMode is set. If it is set to false, 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.

  7. Inventory the installed Capacitor plugins from package.json dependencies. Match these prefixes:

    • @capacitor/*
    • @capawesome/* and @capawesome-team/*
    • @capacitor-community/*
    • @capacitor-firebase/*
    • @capacitor-mlkit/*
    • @revenuecat/*
    • Any other package with "capacitor" in its package.json keywords array

    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

  1. 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/android kept the classes annotated with @CapacitorPlugin but not

Полный SKILL.md на GitHub

Установить 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), без исполняемых скриптов.

Похожие скиллы

Сравнить capacitor-android-dex-optimization с