Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

dulmandakh
Copy link
Contributor

@dulmandakh dulmandakh commented Apr 16, 2019

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.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Partner labels Apr 16, 2019
@dulmandakh dulmandakh closed this Apr 16, 2019
@dulmandakh dulmandakh reopened this Apr 17, 2019
@dulmandakh dulmandakh marked this pull request as ready for review April 17, 2019 23:52
@dulmandakh dulmandakh requested a review from cpojer April 18, 2019 00:03
@dulmandakh dulmandakh changed the title bump android gradle plugin to 3.4.0 [WIP] bump android gradle plugin to 3.4.0 Apr 19, 2019
@dulmandakh
Copy link
Contributor Author

@gengjiawen I found that RNTester app is crashing because JS is not bundled in a release APK. Could you please help me with investigation.

@gengjiawen
Copy link
Contributor

@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 :)
Also cc @Kudo

@Kudo
Copy link
Contributor

Kudo commented Apr 20, 2019

@dulmandakh The root cause is that the building merged assets path is changed.
This patch might works for you.

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

@dulmandakh
Copy link
Contributor Author

@Kudo thank you, it works.

@dulmandakh dulmandakh changed the title [WIP] bump android gradle plugin to 3.4.0 bump android gradle plugin to 3.4.0 Apr 21, 2019
@dulmandakh dulmandakh requested a review from hramos April 21, 2019 02:54
@dulmandakh
Copy link
Contributor Author

@hramos @cpojer it would be great to have R8 and Android Studio 3.4 support in 0.60. Please review and merge.

@hramos hramos self-assigned this Apr 26, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @dulmandakh in 30348f7.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 27, 2019
@mikehardy
Copy link
Contributor

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

@dulmandakh
Copy link
Contributor Author

dulmandakh commented May 15, 2019 via email

@mikehardy
Copy link
Contributor

@dulmandakh thanks for the reply

Your commit comment says Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid.

But here you say:

I disabled R8 for ReactAndroid because it bundles AndroidX appcompat,
okhttp and other libraries in it.

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?

@mikehardy
Copy link
Contributor

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

@dulmandakh
Copy link
Contributor Author

dulmandakh commented May 15, 2019 via email

@mikehardy
Copy link
Contributor

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.

@dulmandakh
Copy link
Contributor Author

dulmandakh commented May 15, 2019 via email

@mikehardy
Copy link
Contributor

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

kelset pushed a commit that referenced this pull request Jun 5, 2019
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
douglowder pushed a commit to react-native-tvos/react-native-tvos that referenced this pull request Sep 11, 2019
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
@dulmandakh dulmandakh deleted the android-gradle-3.4.0 branch October 15, 2019 05:14
KusStar pushed a commit to KusStar/react-native that referenced this pull request Nov 9, 2020
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
KusStar pushed a commit to KusStar/react-native that referenced this pull request Nov 11, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants