capacitor-community / capacitor-community/fcm
bug: Build failure on AGP 9.0+ due to unsupported 'proguard-android.txt'
- Dominant language
- TypeScript
- Stars
- 272
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
### Description:
#### Info:
• Plugin Version: 8.1.0
• Android Gradle Plugin (AGP) Version: 9.2.1
#### Describe the Bug
When building an Android project using Android Gradle Plugin 9.x, the build fails with an exception
evaluating :capacitor-community-fcm because of a call to getDefaultProguardFile('proguard-android.txt') .
Modern versions of AGP and the R8 compiler no longer support proguard-android.txt because it includes the -
dontoptimize flag, which prevents optimization. Instead, AGP requires libraries to use proguard-android-optimize.txt
#### Steps to Reproduce
1. Configure an Android project with AGP 9.x .
2. Add @capacitor-community/fcm .
3. Run `gradlew assembleDebug` or `gradlew assembleRelease` .
#### Error Log / Stack Trace
* Where:
Build file 'node_modules/@capacitor-community/fcm/android/build.gradle' line: 34
* What went wrong:
A problem occurred evaluating project ':capacitor-community-fcm'.
> `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.
#### Suggested Fix
Update the proguardFiles configuration in the plugin's android/build.gradle file to use proguard-android-
optimize.txt instead:
```diff
buildTypes {
release {
minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
```
Contributor guide
Research direction
Open android/build.gradle at line 34 and inspect the release buildTypes proguardFiles configuration. Reproduce with gradlew assembleDebug or gradlew assembleRelease under AGP 9.x, then verify the build succeeds with the supported configuration and the existing proguard-rules.pro file remains included.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, firebase, typescript
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100