-
Notifications
You must be signed in to change notification settings - Fork 44
feat: add proguard/R8 support #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hurali97
wants to merge
6
commits into
main
Choose a base branch
from
hur/feat/add-consumer-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
100d52d
feat: add consumer-rules
hurali97 2c9a2ec
feat: update proguard rules for RNApp
hurali97 061374c
feat: add options for minify and extra proguard rules for android exp…
hurali97 2d453ae
feat: use options in expo app 56
hurali97 03c8cda
docs: update
hurali97 0277842
docs: update
hurali97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@callstack/react-native-brownfield': minor | ||
| '@callstack/brownfield-navigation': minor | ||
| '@callstack/brownie': minor | ||
| '@callstack/brownfield-cli': minor | ||
| --- | ||
|
|
||
| feat: support proguard/R8 minification |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| [ | ||
| "guidelines", | ||
| "minification", | ||
| "troubleshooting", | ||
| { | ||
| "type": "dir", | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Minification | ||
|
|
||
| This guide shows how to enable minification for both Expo and bare React Native brownfield modules. | ||
|
|
||
| ## Expo | ||
|
|
||
| Configure minification through the Brownfield config in `package.json` and let `expo prebuild` apply it to the generated module. | ||
|
|
||
| Steps: | ||
|
|
||
| 1. Add a `brownfield` block to `package.json` and enable `android.expo.minifyEnabled`. | ||
| 2. Add keep rules in `android.expo.extraProguardRules` for generated Brownie store types, navigation types, and host manager classes you need to keep. | ||
| 3. Run `expo prebuild` to regenerate the Android module with the new settings. | ||
|
|
||
| Example (see [apps/ExpoApp56](https://github.com/callstack/react-native-brownfield/blob/main/apps/ExpoApp56/package.json)): | ||
|
|
||
| ```json | ||
| { | ||
| "brownfield": { | ||
| "debug": true, | ||
| "android": { | ||
| "expo": { | ||
| "minifyEnabled": true, | ||
| "extraProguardRules": [ | ||
| // If you're using Brownie, add the generated store here | ||
| "-keep class com.your.expoapp.BrownfieldStore { *; }", | ||
| "-keep class com.your.expoapp.BrownfieldStore$Companion { *; }", | ||
| "-keep class com.your.expoapp.User { *; }", | ||
| "-keep class com.your.expoapp.SettingsStore { *; }", | ||
| "-keep class com.your.expoapp.SettingsStore$Companion { *; }", | ||
| "-keep class com.your.expoapp.Theme { *; }", | ||
|
|
||
| // If you're using Brownfield Navigation, add the generated types here | ||
| "-keep class com.callstack.nativebrownfieldnavigation.UserType { *; }", | ||
|
|
||
| // Any other rule to add | ||
| //"-keep class ..." | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Bare React Native | ||
|
|
||
| For bare React Native, you do not need any Brownfield config. Enable minification in the module itself and add Proguard rules manually. | ||
|
|
||
| Steps: | ||
|
|
||
| 1. In your `brownfieldlib/build.gradle.kts`, enable `isMinifyEnabled = true` in the `release` build type. | ||
| 2. Ensure `proguard-rules.pro` keeps the generated Brownie store types, navigation types, and your host manager if you have one. | ||
|
|
||
| Example (see [apps/RNApp](https://github.com/callstack/react-native-brownfield/blob/main/apps/RNApp/android/app/proguard-rules.pro)): | ||
|
|
||
| ```kts | ||
| android { | ||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = true | ||
| proguardFiles( | ||
| getDefaultProguardFile("proguard-android-optimize.txt"), | ||
| "proguard-rules.pro" | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```json | ||
| // If you're using Brownie, add the generated store here | ||
| -keep class com.rnapp.brownfieldlib.BrownfieldStore { *; } | ||
| -keep class com.rnapp.brownfieldlib.BrownfieldStore$Companion { *; } | ||
| -keep class com.rnapp.brownfieldlib.User { *; } | ||
| -keep class com.rnapp.brownfieldlib.SettingsStore { *; } | ||
| -keep class com.rnapp.brownfieldlib.SettingsStore$Companion { *; } | ||
| -keep class com.rnapp.brownfieldlib.Theme { *; } | ||
|
|
||
| // If you're using Brownfield Navigation, add the generated types here | ||
| -keep class com.callstack.nativebrownfieldnavigation.UserType { *; } | ||
|
|
||
| // Any other rule to add | ||
| //"-keep class ..." | ||
| ``` |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| -keep class com.callstack.nativebrownfieldnavigation.NativeBrownfieldNavigationPackage { *; } | ||
| -keep class com.callstack.nativebrownfieldnavigation.NativeBrownfieldNavigationModule { *; } | ||
| -keep interface com.callstack.nativebrownfieldnavigation.BrownfieldNavigationDelegate { *; } | ||
| -keep class com.callstack.nativebrownfieldnavigation.BrownfieldNavigationManager { *; } |
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
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
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
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
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
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
11 changes: 11 additions & 0 deletions
11
packages/react-native-brownfield/android/consumer-rules.pro
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -keep class com.callstack.reactnativebrownfield.ReactNativeBrownfield { *; } | ||
| -keep class com.callstack.reactnativebrownfield.ReactNativeBrownfield$Companion { *; } | ||
| -keep interface com.callstack.reactnativebrownfield.OnJSBundleLoaded { *; } | ||
| -keep interface com.callstack.reactnativebrownfield.OnMessageListener { *; } | ||
| -keep class com.callstack.reactnativebrownfield.ReactNativeFragment { *; } | ||
| -keep class com.callstack.reactnativebrownfield.ReactNativeFragment$Companion { *; } | ||
| -keep class com.callstack.reactnativebrownfield.ReactDelegateWrapper { *; } | ||
| -keep class com.callstack.reactnativebrownfield.ReactNativeBrownfieldPackage { *; } | ||
| -keep class com.callstack.reactnativebrownfield.ReactNativeBrownfieldModule { *; } | ||
| -keep class com.callstack.reactnativebrownfield.constants.ReactNativeFragmentArgNames { *; } | ||
| -keep class com.callstack.reactnativebrownfield.constants.ReactNativeFragmentArgNames$Companion { *; } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?