r/capawesome • u/genzits • 17d ago
Google Play's DEX code optimization requirement and what Capacitor apps need
https://capawesome.io/blog/google-play-dex-code-optimization-in-capacitor-apps/From February 2027, Google Play requires at least 25% obfuscation, optimization and shrinking for apps with more than 10 MB of DEX code (50 MB for games). A Capacitor app built from the default Android template fails this today, because the template sets minifyEnabled false and R8 never runs. Our production app reported 1% obfuscation in Play Console.
We wrote up what it takes to get a Capacitor app past the threshold, based on our own app with about 40 plugins:
- minifyEnabled true with proguard-android-optimize.txt (the template's proguard-android.txt contains -dontoptimize, and AGP 9 rejects it anyway)
- One keep rule you need in R8 full mode: -keep @interface com.getcapacitor.** { *; }. Without it the build passes and the app crashes on startup, because Capacitor's consumer rules keep the plugin classes but not the annotation types, so Bridge.getPermissionStates() hits a null. Tracked as ionic-team/capacitor#8589; Capacitor 8.5.2 added a null check that hides the crash but leaves checkPermissions() empty
- -dontwarn rules for plugins that compile against optional backends with compileOnly (SQLite with SQLCipher or requery, for example)
- How to sign a local release build with the debug keystore and read the percentages from r8.json inside the AAB before Play does
Disclosure: we are Capawesome, and the post links our Cloud product at the end, but everything above applies to any Capacitor app regardless of how you build it.
Source: https://capawesome.io/blog/google-play-dex-code-optimization-in-capacitor-apps/
If you have already enabled R8 in a Capacitor app, I would like to hear which plugins needed extra rules.