If your Capacitor plugin started failing after upgrading to Android Gradle Plugin 9 (AGP 9), you are likely hitting a small but critical Gradle configuration issue.
This post specifically targets common search intents like:
- Capacitor plugin build error AGP 9
- Android Gradle Plugin 9 plugin build failed
proguard-android.txtnot found- AGP 9
getDefaultProguardFileerror - Capacitor Android build failed after AGP upgrade
The short version:
proguard-android.txtis no longer the safe default baseline to reference in AGP 9 plugin builds.- Switch to
proguard-android-optimize.txt. - Rebuild and verify.
The longer version matters too, especially if you maintain many plugins or large Capacitor workspaces. In this article we cover:
- What Android and AGP are in the build chain
- What Capacitor is and how plugin builds work
- What Capgo is and why this matters for release reliability
- The exact AGP 9 change that breaks old plugin templates
- A safe migration strategy for one repo or many repos
What is Android in this context?
Android is both an operating system and a build ecosystem. When you ship a Capacitor app or plugin on Android, your project goes through:
- Gradle as the build system.
- Android Gradle Plugin (AGP) as Android-specific Gradle integration.
- The Android SDK toolchain for packaging, shrinking, linting, and producing
.aar,.apk, or.aaboutputs.
When AGP versions change, some defaults and internal files can change too. A plugin configuration that worked for AGP 8 can fail on AGP 9 if it points to a removed or deprecated baseline.
What is Capacitor?
Capacitor is a cross-platform runtime that lets you build iOS/Android apps with web code (TypeScript, JavaScript, HTML, CSS) while still calling native APIs.
Capacitor apps usually include:
- A web layer (your UI and business logic)
- Native shells (
ios/,android/) - Plugins that expose native features to JavaScript
Each plugin has its own native build configuration. On Android, this means each plugin includes an android/build.gradle file that AGP must parse and compile correctly.
If plugin Gradle settings are outdated, the whole app build can fail, even when your web code is correct.
What is Capgo?
Capgo provides tools around Capacitor delivery and operations:
- Live updates for web bundle changes
- Plugin ecosystem and native feature packages
- CI/CD-friendly update workflows for Capacitor teams
Even with live updates, native build stability is non-negotiable. You still need clean Android builds for:
- App Store / Play Store releases
- Native plugin upgrades
- Platform SDK migrations
- Team onboarding and CI reliability
That is why AGP 9 compatibility fixes are important: they keep your plugin layer dependable so delivery pipelines stay predictable.
Why AGP 9 breaks older plugin configs
Many plugin templates historically used:
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'In AGP 9 setups, this legacy baseline reference can fail because the old file is no longer guaranteed in the location expected by older templates/configs.
Typical symptoms include Gradle errors during assemble, lint, or build phases, often pointing to missing ProGuard baseline resources or invalid default file references.
Quick background: ProGuard, R8, and baseline files
- R8 is the modern code shrinker/optimizer in Android builds.
proguard-rules.prois your project/plugin custom keep rules.getDefaultProguardFile(...)injects an Android-provided baseline.
When you reference:
proguard-android.txt-> legacy, minimal baselineproguard-android-optimize.txt-> modern optimized baseline (recommended default in current setups)
For AGP 9 compatibility, switching to proguard-android-optimize.txt is the practical fix.
The one-line fix
Update plugin and app module Gradle files:
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'At minimum, check:
android/build.gradlein each pluginexample-app/android/app/build.gradlein plugin repos- Any generator/template files that create new plugin Gradle config
Migration guide for one plugin
1. Find the old reference
rg -n "proguard-android\\.txt" android example-app2. Replace it
perl -pi -e "s/proguard-android\\.txt/proguard-android-optimize.txt/g" \ android/build.gradle example-app/android/app/build.gradle3. Verify with Bun
bun run verify:androidIf your plugin has full verification scripts, run:
bun run verifyBatch update all plugin repos
If you maintain many plugin repositories in one workspace, automate it:
rg -l "proguard-android\\.txt" capacitor-* \ --glob '!**/node_modules/**' \ --glob '!**/.gradle/**' \ --glob '!**/build/**' \| xargs perl -pi -e "s/proguard-android\\.txt/proguard-android-optimize.txt/g"Then validate that no tracked plugin source still uses the old file:
for d in capacitor-*; do [ -d "$d/.git" ] || continue git -C "$d" grep -n "proguard-android\\.txt" -- || truedoneNo matches means the old baseline reference is gone from tracked plugin files.
Capgo rollout status
We completed this migration across all official Capgo Capacitor plugin repositories and templates:
- Plugin Android modules now reference
proguard-android-optimize.txt - Plugin example Android apps were updated too
- Plugin scaffolding templates were updated so new plugins are AGP 9-safe by default
This prevents a common class of AGP 9 upgrade failures before they hit CI.
Why this is important even if your build passes today
You might not see failures immediately if:
- Your CI cache still masks the issue
- You have mixed AGP versions across projects
- Only some modules are rebuilt in local dev
But eventually, clean builds, new environments, or upgraded runners expose it. Doing the migration now removes hidden instability.
Troubleshooting if builds still fail after the replacement
Check these points:
-
Every module is patched. Look at plugin modules, app modules, samples, and template assets.
-
There is no second reference in shared scripts. Search entire repositories (including custom Gradle scripts).
-
Caches are clean. Run
./gradlew cleanand rebuild. -
AGP / Gradle / JDK versions are aligned. Use combinations supported by Android documentation for your AGP version.
-
CI uses the same versions as local. Pin JDK and Gradle wrapper versions in CI to avoid environment drift.
-
You are not patching only
node_modules. Fix tracked plugin source, not transient dependency directories.
SEO FAQ: AGP 9 Capacitor plugin build errors
How do I fix proguard-android.txt not found in AGP 9?
Replace:
getDefaultProguardFile('proguard-android.txt')With:
getDefaultProguardFile('proguard-android-optimize.txt')Then run a clean rebuild.
Why does my Capacitor plugin build fail after upgrading to Android Gradle Plugin 9?
Most failures come from legacy Gradle config in plugin android/build.gradle files that still reference proguard-android.txt. AGP 9 projects should use proguard-android-optimize.txt.
What is the fastest AGP 9 migration path for many Capacitor plugins?
Use a workspace-wide search-and-replace command, then validate with git grep and run bun run verify:android on representative plugins.
Is this only a Capacitor issue?
No. Any Android module (app or library) using deprecated ProGuard baseline references can hit similar AGP 9 build errors. It is especially visible in plugin ecosystems because many repositories share old templates.
What keywords are relevant for this migration?
If you are documenting this in internal runbooks or support pages, include terms like:
- AGP 9 build error
- Android Gradle Plugin 9 ProGuard file missing
- Capacitor plugin Android build failed
proguard-android.txtreplacementproguard-android-optimize.txtmigration
Related links
- Android Developers: Build your app overview
- Android Gradle Plugin: Release notes
- Android code shrinking: R8 and rules
- Gradle docs: Build tool fundamentals
- Capacitor docs: Official documentation
- Capgo docs: Auto update docs
Final takeaway
This AGP 9 issue is simple, but it is easy to miss in multi-plugin workspaces. Once you replace proguard-android.txt with proguard-android-optimize.txt everywhere relevant, Android builds become predictable again.
If you use Capgo plugins, this migration is already applied in official repositories so you can upgrade with fewer surprises.