fix(android): [SDK-5061] use proguard-android-optimize.txt for AGP 9 - #1971
Merged
Conversation
AGP 9 rejects getDefaultProguardFile('proguard-android.txt') at project
evaluation because that default includes -dontoptimize, which breaks
React Native 0.87 apps before they even compile.
Co-authored-by: Cursor <cursoragent@cursor.com>
fadi-george
approved these changes
Aug 27, 2026
fadi-george
left a comment
Collaborator
There was a problem hiding this comment.
Seems good, its a similar change we did for capacitor.
Tested w/ agp 8 and 9.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Switch
getDefaultProguardFilefromproguard-android.txttoproguard-android-optimize.txtso the Android module evaluates under AGP 9 / React Native 0.87.Details
Motivation
Fixes #1970 (SDK-5061).
React Native 0.87 is the first RN release that requires Android Gradle Plugin 9. AGP 9 rejects
getDefaultProguardFile('proguard-android.txt')during project evaluation because that default includes-dontoptimize, which disables most R8 optimizations. The consumer error is:This fails before Java/Kotlin compile or minify. The published module (
android/build.gradle) is what apps evaluate via autolinking; the demo apps are updated so they stay AGP 9-safe as well. Theoptimizedefault is valid on AGP 8, so RN 0.84 consumers are unchanged.Scope
android/build.gradle(published with the npm package)examples/demo,examples/demo-no-location)android/proguard-rules.prois still empty; the native Android SDK ships its own consumer rules)Testing
Unit testing
No automated test is added, and current CI cannot catch this class of regression.
The failure is AGP 9 configuration-time, not minify-time. Our PR CI (
wrapper-js-ci) runs JS lint/tests plusexamples/demo/android/gradlew spotlessCheck. That does evaluate:react-native-onesignal, but the demo is still React Native 0.84, which pins AGP 8.12. AGP 8 still acceptsproguard-android.txt, so bothspotlessCheckand e2eassembleReleasewould stay green on the broken 5.5.7 line.A true reproduction needs a Gradle evaluation under AGP 9. That means a React Native 0.87 host:
android/build.gradleappliescom.facebook.react, so a standalone AGP 9 fixture cannot evaluate the published module without the RN Gradle plugin. Bumping the demo to 0.87 is the real future gate (gradlew help/spotlessCheck/assembleReleasewould then fail on the old default). That bump is out of scope here.A static grep for
getDefaultProguardFile('proguard-android.txt')would fail closed on this exact string without AGP 9, but it would not prove the rest of the module still evaluates under AGP 9, and it would not have caught a dynamically constructed filename. Until the demo is on RN 0.87, there is no CI job that exercises the actual consumer failure.Manual testing
Not run on a RN 0.87 app in this PR. The change is the replacement AGP itself recommends, and it is the same one-line fix used by other AGP 9 library plugins.
Affected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor