Skip to content

feat: add proguard/R8 support#422

Open
hurali97 wants to merge 6 commits into
mainfrom
hur/feat/add-consumer-rules
Open

feat: add proguard/R8 support#422
hurali97 wants to merge 6 commits into
mainfrom
hur/feat/add-consumer-rules

Conversation

@hurali97

@hurali97 hurali97 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

This adds the consumer-rules to the packages and exposes 2 options, minifyEnabled and extraProguardRules for brownfield.android.expo.

Test plan

  • Verified locally on both Expo and RN App
  • CI passes

@hurali97 hurali97 changed the title feat/add consumer rules feat: add proguard/R8 support Jul 9, 2026
@hurali97 hurali97 marked this pull request as ready for review July 9, 2026 05:35
Copilot AI review requested due to automatic review settings July 9, 2026 05:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hurali97 hurali97 requested a review from artus9033 July 9, 2026 05:36

@artus9033 artus9033 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.

LGTM, just one comment left

Comment on lines +19 to +35
"brownfield": {
"debug": true,
"android": {
"expo": {
"minifyEnabled": false,
"extraProguardRules": [
"-keep class com.callstack.rnbrownfield.demo.expoapp56.BrownfieldStore { *; }",
"-keep class com.callstack.rnbrownfield.demo.expoapp56.BrownfieldStore$Companion { *; }",
"-keep class com.callstack.rnbrownfield.demo.expoapp56.User { *; }",
"-keep class com.callstack.rnbrownfield.demo.expoapp56.SettingsStore { *; }",
"-keep class com.callstack.rnbrownfield.demo.expoapp56.SettingsStore$Companion { *; }",
"-keep class com.callstack.rnbrownfield.demo.expoapp56.Theme { *; }",
"-keep class com.callstack.nativebrownfieldnavigation.UserType { *; }"
]
}
}
},

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.

Shouldn't we add this to ExpoApp55 too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's only required if we use minification enabled and I guess for showcase perspective, doing in one app is fine?

@yassinetou9

Copy link
Copy Markdown

@hurali97 @artus9033 The extraProguardRules array is joined directly into the generated proguard-rules.pro file with no validation. Invalid ProGuard syntax will only be caught at Gradle build time, making it hard to diagnose.

Consider adding a simple validation check in resolveBrownfieldPluginConfig or when rendering the template. For example:

const extraProguardRules = (effectiveProps.android?.extraProguardRules ?? [])
  .filter(rule => rule.trim().length > 0);

And document in the schema that each rule must be a non-empty string. This catches silent failures early.

@yassinetou9

Copy link
Copy Markdown

@hurali97 @artus9033 The -dontwarn rules for Material and Java invoke classes appear in:

  • packages/react-native-brownfield/src/expo-config-plugin/template/android/proguard-rules.pro
  • apps/RNApp/android/BrownfieldLib/proguard-rules.pro

These rules are identical and could be centralized in the consumer-rules.pro of the main package so they're automatically included wherever the package is used, eliminating duplication.

-dontwarn com.google.android.material.R$attr
-dontwarn com.google.android.material.R$dimen
-dontwarn com.google.android.material.R$id
-dontwarn com.google.android.material.R$style
-dontwarn java.lang.invoke.StringConcatFactory

This reduces maintenance burden if these rules ever need to change.

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.

4 participants