---
title: How to Fix Capacitor Plugin Build Errors with AGP 9
description: Learn how to fix Android Gradle Plugin 9 build errors in Capacitor apps caused by the deprecated proguard-android.txt file.
date:
  created: 2026-02-19
authors:
  - robingenz
categories:
  - Capacitor
  - Guides
---

# How to Fix Capacitor Plugin Build Errors with AGP 9

If you recently upgraded to Android Gradle Plugin (AGP) 9 in your Capacitor project, you may have noticed that your Android build suddenly fails. AGP 9 introduces a breaking change that affects Capacitor core and many Capacitor plugins. The good news: fixes are already available.

<!-- more -->

<div class="capawesome-z29o10a">
  <a href="/" target="_blank">
    <img alt="Build and deploy your Capacitor app with Capawesome Cloud" src="https://capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.png?t=1" />
  </a>
</div>

## The Problem

Android Studio may suggest upgrading your Android Gradle Plugin dependency from 8.x to 9.0.0. After accepting this upgrade, your build fails with an error like this:

```
A problem occurred evaluating project ':app'.
> `getDefaultProguardFile('proguard-android.txt')` is no longer supported since it includes
`-dontoptimize`, which prevents R8 from performing many optimizations. Instead use
`getDefaultProguardFile('proguard-android-optimize.txt')`, and if needed, temporarily use
`-dontoptimize` in a custom keep rule file while fixing breakages.
```

The root cause is that AGP 9 [removed support](https://github.com/ionic-team/capacitor/issues/8314){:target="_blank"} for the `proguard-android.txt` default ProGuard file. This file was previously used by Capacitor core and many Capacitor plugins. Since AGP 9 now requires `proguard-android-optimize.txt` instead, any plugin still referencing the old file will cause the build to fail.

This affects not only your app's `build.gradle`, but also the `build.gradle` files of individual Capacitor plugins that ship their own ProGuard configuration.

## The Fix

There are two ways to resolve this issue:

### Option 1: Update Your Dependencies

The Capacitor team has already [merged a fix](https://github.com/ionic-team/capacitor/pull/8315){:target="_blank"} that replaces `proguard-android.txt` with `proguard-android-optimize.txt` in Capacitor core. The same fix has been applied to all official Capacitor plugins.

To resolve the issue, update `@capacitor/core`, `@capacitor/android`, and all official Capacitor plugins to their latest versions:

```bash
npm install @capacitor/core@latest @capacitor/android@latest
```

Make sure to also update any official Capacitor plugins (e.g. `@capacitor/app`, `@capacitor/device`, etc.) to their latest versions.

### Option 2: Opt Out of the New Behavior

If you can't update all your dependencies right away, you can opt out of the breaking change by adding the following line to your `android/gradle.properties` file:

```properties title="android/gradle.properties"
android.r8.proguardAndroidTxt.disallowed=false
```

This restores support for `proguard-android.txt` and allows your project to build with AGP 9 without updating any plugins. Note that this is only a temporary workaround and may be removed in a future AGP version.

## Capawesome Plugins

All Capacitor plugins from [Capawesome](/) are already compatible with AGP 9. The fix has been included in the latest version of every Capawesome plugin, so simply updating to the latest version is all you need to do.

## FAQ

### How do I fix "proguard-android.txt is no longer supported"?

Replace `proguard-android.txt` with `proguard-android-optimize.txt` in your app's `build.gradle` and update all Capacitor plugins to their latest versions. Alternatively, add `android.r8.proguardAndroidTxt.disallowed=false` to your `gradle.properties` as a temporary workaround.

### Is this just a Capacitor issue?

No. Any Android project or library that references `proguard-android.txt` will break with AGP 9. Capacitor apps are commonly affected because both Capacitor core and many plugins used this file.

### Do I need to update all my plugins at once?

Not necessarily. If you can't update everything immediately, use the `gradle.properties` opt-out flag to unblock your build while you update plugins incrementally.

### Will the opt-out flag work forever?

No. The `android.r8.proguardAndroidTxt.disallowed=false` flag is a temporary escape hatch. It may be removed in a future AGP version, so you should plan to update your dependencies.

### Does this affect Capacitor community plugins too?

Yes. Any community plugin that references `proguard-android.txt` in its `build.gradle` will need to be updated. Check with the plugin maintainer or submit a PR replacing the file reference.

### Can I stay on AGP 8 to avoid this?

Yes, staying on AGP 8.x avoids the issue entirely. However, future versions of Android Studio will eventually require AGP 9, so it's better to address the change sooner rather than later.

## Related Posts

- [How to patch a Capacitor plugin](./how-to-patch-a-capacitor-plugin.md)
- [The Android Troubleshooting Guide for Capacitor](./troubleshooting-capacitor-android-issues.md)
- [The iOS Troubleshooting Guide for Capacitor](./troubleshooting-capacitor-ios-issues.md)
- [How to Upgrade Your Capacitor App to Capacitor 8](./how-to-upgrade-your-capacitor-app-to-capacitor-8.md)

## Stay Updated

Want to stay informed about Capacitor compatibility updates and new plugin releases? Subscribe to our newsletter:

[Subscribe to the Capawesome Newsletter](/newsletter/){ .md-button .md-button--primary }

## Conclusion

AGP 9 introduces a breaking change by removing support for the `proguard-android.txt` default ProGuard file. This causes build failures in Capacitor apps and plugins that still reference it. The fix is straightforward: update Capacitor core, your plugins, and your app's `build.gradle` to use `proguard-android-optimize.txt` instead.

If you have questions or run into other issues, join the [Capawesome Discord server](https://discord.gg/VCXxSVjefW){:target="_blank"} to get help from the community. And don't forget to subscribe to the [Capawesome newsletter](/newsletter/){:target="_blank"} to stay up to date on the latest news and updates.
