Android build fails with AGP 9 because proguard-android.txt is no longer supported
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 2.9k
- Forks
- 947
- Avg merge
- 6d 37m
- Merged PRs (30d)
- 1
Description
Environment
- React Native: 0.87.0
- @rnmapbox/maps: 10.3.5
- Android Gradle Plugin: 9.0+
- Gradle: 9.4.1
Problem
Android builds fail during Gradle configuration because the library uses the legacy proguard-android.txt file:
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Starting with AGP 9, getDefaultProguardFile() no longer supports proguard-android.txt.
Error
getDefaultProguardFile('proguard-android.txt') is no longer supported.
Instead, use getDefaultProguardFile('proguard-android-optimize.txt').
Workaround
Replacing:
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
with:
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
fixes the build.
Additional information
According to the AGP 9 release notes, proguard-android.txt is no longer supported because it contains the -dontoptimize flag, which disables many R8 optimizations.
Google now recommends using proguard-android-optimize.txt as the default configuration.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the Android Gradle configuration for the proguardFiles declaration shown in the issue and inspect the surrounding release-build setup. Replace the unsupported legacy default with the recommended AGP 9 configuration, then verify that an Android build using AGP 9 and Gradle 9.4.1 completes without the configuration error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin, react-native
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100