Fix Capacitor plugin build errors with AGP 9
Android Gradle Plugin 9 breaks older Capacitor plugin builds with namespace and compileSdk errors. What actually fails, the exact fixes, and how to unblock your Android build fast.
Upgraded to Android Gradle Plugin 9 and your Capacitor build suddenly fails with namespace orcompileSdk errors on a plugin that worked yesterday? AGP 9 tightened several requirements that older Capacitor plugins didn't meet. This guide covers what actually breaks and the fastest way to get your Android build green again.
These are native build errors, so the fix ships in your next store binary, not over the air. Once you're building again, OtaKit keeps shipping the web layer without further store trips.
The usual failures
- Missing namespace — AGP 9 requires every module to declare a
namespacein itsbuild.gradle; the oldpackageattribute in the manifest is no longer accepted. - compileSdk / minSdk floors — AGP 9 raises the minimums; a plugin pinned low won't compile.
- Removed/renamed Gradle APIs — older plugin Gradle scripts calling deprecated APIs break outright.
Fix 1: update the plugins
The clean fix is upgrading the offending plugins to versions that support AGP 9 — maintainers have largely shipped these. Align your Capacitor core, CLI, and plugins to compatible versions first; a version mismatch masquerades as an AGP error surprisingly often. See fixing version mismatch errors.
Fix 2: add the namespace
If a plugin is unmaintained, you can patch its module to add a namespace:
android {
namespace "com.example.theplugin"
compileSdk 35
}Fix 3: bump the SDK floors
Raise compileSdk (and minSdk if needed) in your app-level build.gradle and variables file to meet AGP 9's requirements, then re-sync.
If a single unmaintained plugin is holding back the whole build, that's a signal to replace it. A stuck native dependency you can't update becomes the thing that blocks every future Android release.
Where to go next
See resolving Android build errors for the broader triage and the 16KB page-size requirement, another recent Android gotcha.