-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Android release build with proguard enabled throws exception at start #6624
Comments
@facebook-github-bot label android |
Yeah, currently enabling proguard breaks the build. Would be great if someone could look into fixing this. cc @mkonicek |
I tried manually adding both |
Thanks for looking into it. Much appreciated.
|
Found the problem.
|
Finally found this issue. Saved my day. |
The problem is still exists. I created a project with
Then I added proguard, build and run release version, app crashed:
proguard-rules.pro was copied from master: https://gist.github.com/cpunion/f0712cae8ad552f9d49db86cc60ebeb4 |
@cpunion RN Android does not build from source code by default because it's quite slow and requires Android NDK installed in order to build JavaScriptCore. You need to either update to 0.24 RC or follow this guide to set up your gradle script to compile RN Android from source: |
@cpunion of course much easier solution would be to add a line to your project proguard config that I mentioned here: |
@dgladkov Thanks so much, it works find. |
Summary:Fixes proguard in RN 0.22.+. Closes facebook#6624 Closes facebook#6626 Differential Revision: D3092892 fb-gh-sync-id: 3aaf97c6f1c7b5d575cb912196b43955d9ef10fb shipit-source-id: 3aaf97c6f1c7b5d575cb912196b43955d9ef10fb
Add also
|
Uh the Proguard config files are quite fragile. We have to keep adding stuff to them. Having a test on Circle CI that runs Proguard would help. Could anyone add that test? Could you please send a pull request adding the lines to the default RN Proguard config, such as:
|
I`l do that |
Summary: The original proguard rules are put in the template, which is not very convenient and easy to get wrong. Because new rules get put, people also has two copy paste the rule. And there are also existing project import react native as a dependency. So the best way to keep a android library project proguard rule is to manage the rule itself, using `consumerProguardFiles` like [dagger](https://github.com/JakeWharton/butterknife/blob/46baef6d96e93a1872efa17fdfc1d2af59b36f0c/butterknife/build.gradle#L9) and other android library project. <!-- Required: Write your motivation here. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Use RNTester to build the release flavor (now it has bugs #18460, I keep my change in local for now), after build success, run to check if crash. In the process, I also fix #12994 and #6624 by adding the following to proguard rules ```proguard -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } ``` <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [ANDROID] [ENHANCEMENT and BUGFIX] [Proguard rules] - inline and fix proguard rules . <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes #18461 Differential Revision: D7527533 Pulled By: hramos fbshipit-source-id: 447dbc16983bcfb597187b40c1be3987a8c5a832
Summary: The original proguard rules are put in the template, which is not very convenient and easy to get wrong. Because new rules get put, people also has two copy paste the rule. And there are also existing project import react native as a dependency. So the best way to keep a android library project proguard rule is to manage the rule itself, using `consumerProguardFiles` like [dagger](https://github.com/JakeWharton/butterknife/blob/46baef6d96e93a1872efa17fdfc1d2af59b36f0c/butterknife/build.gradle#L9) and other android library project. <!-- Required: Write your motivation here. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Use RNTester to build the release flavor (now it has bugs facebook#18460, I keep my change in local for now), after build success, run to check if crash. In the process, I also fix facebook#12994 and facebook#6624 by adding the following to proguard rules ```proguard -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } ``` <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [ANDROID] [ENHANCEMENT and BUGFIX] [Proguard rules] - inline and fix proguard rules . <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes facebook#18461 Differential Revision: D7527533 Pulled By: hramos fbshipit-source-id: 447dbc16983bcfb597187b40c1be3987a8c5a832
Summary: The original proguard rules are put in the template, which is not very convenient and easy to get wrong. Because new rules get put, people also has two copy paste the rule. And there are also existing project import react native as a dependency. So the best way to keep a android library project proguard rule is to manage the rule itself, using `consumerProguardFiles` like [dagger](https://github.com/JakeWharton/butterknife/blob/46baef6d96e93a1872efa17fdfc1d2af59b36f0c/butterknife/build.gradle#L9) and other android library project. <!-- Required: Write your motivation here. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Use RNTester to build the release flavor (now it has bugs facebook#18460, I keep my change in local for now), after build success, run to check if crash. In the process, I also fix facebook#12994 and facebook#6624 by adding the following to proguard rules ```proguard -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } ``` <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [ANDROID] [ENHANCEMENT and BUGFIX] [Proguard rules] - inline and fix proguard rules . <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes facebook#18461 Differential Revision: D7527533 Pulled By: hramos fbshipit-source-id: 447dbc16983bcfb597187b40c1be3987a8c5a832
Summary: The original proguard rules are put in the template, which is not very convenient and easy to get wrong. Because new rules get put, people also has two copy paste the rule. And there are also existing project import react native as a dependency. So the best way to keep a android library project proguard rule is to manage the rule itself, using `consumerProguardFiles` like [dagger](https://github.com/JakeWharton/butterknife/blob/46baef6d96e93a1872efa17fdfc1d2af59b36f0c/butterknife/build.gradle#L9) and other android library project. <!-- Required: Write your motivation here. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Use RNTester to build the release flavor (now it has bugs facebook#18460, I keep my change in local for now), after build success, run to check if crash. In the process, I also fix facebook#12994 and facebook#6624 by adding the following to proguard rules ```proguard -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } ``` <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [ANDROID] [ENHANCEMENT and BUGFIX] [Proguard rules] - inline and fix proguard rules . <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes facebook#18461 Differential Revision: D7527533 Pulled By: hramos fbshipit-source-id: 447dbc16983bcfb597187b40c1be3987a8c5a832
Summary: The original proguard rules are put in the template, which is not very convenient and easy to get wrong. Because new rules get put, people also has two copy paste the rule. And there are also existing project import react native as a dependency. So the best way to keep a android library project proguard rule is to manage the rule itself, using `consumerProguardFiles` like [dagger](https://github.com/JakeWharton/butterknife/blob/46baef6d96e93a1872efa17fdfc1d2af59b36f0c/butterknife/build.gradle#L9) and other android library project. <!-- Required: Write your motivation here. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Use RNTester to build the release flavor (now it has bugs facebook#18460, I keep my change in local for now), after build success, run to check if crash. In the process, I also fix facebook#12994 and facebook#6624 by adding the following to proguard rules ```proguard -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } ``` <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [ANDROID] [ENHANCEMENT and BUGFIX] [Proguard rules] - inline and fix proguard rules . <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes facebook#18461 Differential Revision: D7527533 Pulled By: hramos fbshipit-source-id: 447dbc16983bcfb597187b40c1be3987a8c5a832
I get following exception on my release APK with proguard enabled after upgrading RN to 0.22.+. Disabling proguard solves the issue.
The text was updated successfully, but these errors were encountered: