Skip to content

fix(android): [SDK-5061] use proguard-android-optimize.txt for AGP 9 - #1971

Merged
abdulraqeeb33 merged 1 commit into
mainfrom
ar/sdk-5061
Aug 27, 2026
Merged

fix(android): [SDK-5061] use proguard-android-optimize.txt for AGP 9#1971
abdulraqeeb33 merged 1 commit into
mainfrom
ar/sdk-5061

Conversation

@abdulraqeeb33

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Switch getDefaultProguardFile from proguard-android.txt to proguard-android-optimize.txt so 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:

A problem occurred evaluating project ':react-native-onesignal'.
> `getDefaultProguardFile('proguard-android.txt')` is no longer supported since it includes `-dontoptimize`...

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. The optimize default is valid on AGP 8, so RN 0.84 consumers are unchanged.

Scope

  • android/build.gradle (published with the npm package)
  • example app Gradle files (examples/demo, examples/demo-no-location)
  • No native/JS API changes, no keep-rule changes (android/proguard-rules.pro is 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 plus examples/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 accepts proguard-android.txt, so both spotlessCheck and e2e assembleRelease would 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.gradle applies com.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 / assembleRelease would 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

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

Made with Cursor

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>
@abdulraqeeb33
abdulraqeeb33 requested a review from a team as a code owner August 27, 2026 16:44
@abdulraqeeb33 abdulraqeeb33 self-assigned this Aug 27, 2026

@fadi-george fadi-george left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, its a similar change we did for capacitor.
Tested w/ agp 8 and 9.

@abdulraqeeb33
abdulraqeeb33 merged commit 31777da into main Aug 27, 2026
6 checks passed
@abdulraqeeb33
abdulraqeeb33 deleted the ar/sdk-5061 branch August 27, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Android getDefaultProguardFile('proguard-android.txt') is no longer supported since it includes -dontoptimize

2 participants