-
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
bump android gradle plugin to 3.4.0 #24463
Conversation
@gengjiawen I found that RNTester app is crashing because JS is not bundled in a release APK. Could you please help me with investigation. |
I may have some time on weekends :) |
@dulmandakh The root cause is that the building merged assets path is changed. diff --git a/react.gradle b/react.gradle
index 142a21c8a2..f941d0c0b5 100644
--- a/react.gradle
+++ b/react.gradle
@@ -148,6 +148,10 @@ afterEvaluate {
into ("merged_assets/${variant.name}/merge${targetName}Assets/out") {
from(jsBundleDir)
}
+ // Workaround for Android Gradle Plugin 3.4+ new asset directory
+ into ("merged_assets/${variant.name}/out") {
+ from(jsBundleDir)
+ }
}
// mergeAssets must run first, as it clears the intermediates directory |
@Kudo thank you, it works. |
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.
@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @dulmandakh in 30348f7. When will my fix make it into a release? | Upcoming Releases |
I realize this is closed and merged, but is there an issue tracking the need to alter code-shrink declarations so R8 may be enabled? We won't be able to disable it in the future and I see no linked issue and a search for android r8 in the tracker didn't return anything that seemed right |
I disabled R8 for ReactAndroid because it bundles AndroidX appcompat,
okhttp and other libraries in it.
|
@dulmandakh thanks for the reply Your commit comment says But here you say:
Does it bundle them, or strip them? R8 is a shrinker, so I am going to assume you meant that it strips them, while ReactAndroid is supposed to bundle them? I just want to be clear so we can reason about it. If my assumption is correct (ReactAndroid should bundle them - and I think it should yes - while D8 is incorrectly stripping them) then the solution is to modify the shrinking declarations I believe? That's what I am getting at - that there should be an issue to modify those declarations so that R8 is not disabled, because it is the future of the android build toolchain I believe the work would take place here: https://github.com/facebook/react-native/blob/master/ReactAndroid/proguard-rules.pro vs disabling R8 Are there specific crashes associated with this, such that the rules can be modified as needed? |
associated reading (for interested parties) with context, link to FAQs and where to file R8 bugs if needed https://developer.android.com/studio/releases#r8-default |
If enabled R8 will strip out unused classes, so I disabled it.
We bundle AppCompat and other libraries to be used in apps or libraries
that use ReactAndroid, so we don't know which classes will be used by them.
Thus, it's not possible to have proguard rules. So the safest way is to
disable R8 for ReactAndroid and deliver ReactAndroid, other libraries
intact.
|
Ok - that makes sense - may I assume that at the app level - the consumers of ReactAndroid - if they are using R8 it will still shrink correctly? I think so, and I should test myself but you may know already. |
RNTester was slightly smaller with R8 than Proguard. Also much smaller
compared to minification disabled. Please double check.
|
Will do - I think this was all just me not fully understanding separation between R8 in ReactAndroid as a library, and an app. Thanks for responding |
Summary: This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly. Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid. [Android] [Changed] - bump Android Gradle plugin to 3.4.0 Pull Request resolved: #24463 Differential Revision: D15107117 Pulled By: hramos fbshipit-source-id: 35a03dc9955e889c9399faeaf9a862e0fc044fc4 # Conflicts: # ReactAndroid/gradle.properties # build.gradle # template/android/build.gradle
Summary: This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly. Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid. [Android] [Changed] - bump Android Gradle plugin to 3.4.0 Pull Request resolved: facebook/react-native#24463 Differential Revision: D15107117 Pulled By: hramos fbshipit-source-id: 35a03dc9955e889c9399faeaf9a862e0fc044fc4 # Conflicts: # ReactAndroid/gradle.properties # build.gradle # template/android/build.gradle
Summary: This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly. Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid. [Android] [Changed] - bump Android Gradle plugin to 3.4.0 Pull Request resolved: facebook#24463 Differential Revision: D15107117 Pulled By: hramos fbshipit-source-id: 35a03dc9955e889c9399faeaf9a862e0fc044fc4
Summary: This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly. Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid. [Android] [Changed] - bump Android Gradle plugin to 3.4.0 Pull Request resolved: facebook#24463 Differential Revision: D15107117 Pulled By: hramos fbshipit-source-id: 35a03dc9955e889c9399faeaf9a862e0fc044fc4
Summary
This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly.
Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid.
Changelog
[Android] [Changed] - bump Android Gradle plugin to 3.4.0
Test Plan
CI is green, and everything works as normal.