-
Notifications
You must be signed in to change notification settings - Fork 658
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
Fix Android behaviour with Android Gradle Plugin >=4.2.0 #609
Conversation
…not Gradle Execute
May I know which version of gradle plugin you use for this fixing? For RN-0.65.1 they used 4.2.1. I try to implement but still got some errors, Need help, thanks |
I've verified this with |
@octsiri I'm using the same as @mlazari is using. It's the same versions as RN-0.65.1 uses. You also get errors when updating to 4.2.x if you're using an old version of Android Studio, make sure you're on the latest. I expect your errors are likely due to something different. If you're using the "quick fix" way of editing a file in |
@sanduluca Thanks for approving - what needs to be done to merge this? |
Thank you @bwindsor |
When will this change be added to a release tag? |
Cherry pick commit from lugg#609
Cherry pick commit from lugg#609
React Native 0.65 upgraded the Android Gradle Plugin to 4.2.1, which causes anything using
react-native-config
to fail with the following error:Gradle has multiple phases: https://docs.gradle.org/current/userguide/build_lifecycle.html. The reason for this error is that Gradle executes the contents of
task.doFirst
during the execution phase. However, during execution thenbuildConfigFields
isfinal
so cannot be modified. It can only be modified during the configure phase.This PR removes the
task.doFirst
callback, and simply executes the code inside the callback immediately during the configure phase. This has been tested by myself and some other users (see #567) and still works with multiple build types and multiple flavors, both with gradle plugin4.1.x
and4.2.x
.My assumption as to why this upgrade broke
react-native-config
is that Gradle decided to strictly enforce thatbuildConfigFields
isfinal
during the execution phase, whereas in previous versions it probably wasn't enforced but should have been. Google are aware of this change in behaviour (https://issuetracker.google.com/issues/172657565) and closed the issue with a Won't fix (intended behaviour) response. So it's up toreact-native-config
to change to be compatible with this new behaviour.Fixes #567
Fixes #578
Fixes #608