-
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
build: Bump AGP to 7.1.1 and fix bundle inclusion in release mode #33057
Conversation
Base commit: 802b3f7 |
ab972e0
to
cb6aedb
Compare
Base commit: 802b3f7 |
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.
Awesome stuff! 🚀 The only thing missing is to replicate the login also here: https://github.com/facebook/react-native/blob/main/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt
react.gradle
Outdated
from(jsBundleDir) | ||
// Workaround for Android Gradle Plugin 3.4+ new asset directory | ||
into ("merged_assets/${variant.name}/out") { | ||
from(jsBundleDir) |
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.
Can I ask you to refactor a bit here. We don't need all those from(jsBundleDir)
. We just need one into the top-level task (line 306 essentially).
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.
Sure, I've kept just one from(jsBundleDir)
as you suggested
react.gradle
Outdated
into ("assets/${targetPath}") { | ||
// Workaround for Android Gradle Plugin 7.1 asset directory | ||
if (androidComponents.pluginVersion.major == 7 && androidComponents.pluginVersion.minor == 1) { |
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.
I'm not entirely sure we need a if-then-else. We can just add another into
directive. I believe other folders will be ignored (or at the end of the day, you'll end up having just one bundle file regardless).
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.
Makes sense, I've just removed it
3c0db91
to
ed1098a
Compare
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There is a bump missing inside the |
c0fb276
to
3a69046
Compare
I see that the CI is failing with:
That usually happens when the I had to address this for AGP 7.0.x here: react-native/ReactAndroid/build.gradle Lines 418 to 421 in 1a83dc3
I'm unsure why this broke for 7.1.x. I believe the task name/ordering changed inside AGP. |
3a69046
to
00361a5
Compare
@cortinico do you know if we need to specify the Active ABI to set that it depends on preBuild? Something like |
3663869
to
00361a5
Compare
Nope we should not (I believe). The ABI you see in square brackets is just an indication of which ABI has been built at the moment, and is not a real task. As a tip for debugging: |
@cortinico Actaully running |
Then I was wrong here :/ It seems like AGP introduced per-ABI tasks (which is going to be a bit of a pain for us). Then, you'll have to add explicit dependency between Also please star this issue: https://issuetracker.google.com/issues/207403732 |
00361a5
to
704fe25
Compare
I explicitly added the |
@cortinico this was failing due to a missing task dependency on |
The only place where I think it's worth extra care is here: react-native/template/android/app/build.gradle Lines 183 to 189 in fa85417
Have you tried if a new template works out of the box. I'm under the impression we need this extra handling also there, because the |
Yeah, I've just double-checked it using |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
So some updates here. For @gabrieldonadel, in order to land this, we'll need to setup
I'd say let's go for the Doctor check + docs approach for 0.68. I'd like to have a stable RN version that runs on AGP 7.0.x. 7.1 was out just one month ago and I want to make sure we don't push too strong on consumer for updating their deps (that's true that there are users updating eagerly, but we also have a lot of other users which are not updating that fast).
To follow up on this: I'd love to migrate some of our tasks to use the AGP Artifacts API. That would allow to have a more declarative approach on the transformation we apply to the APK and will ideally break less often in the future. |
Sounds like a good plan, I might need some help on this because I'm not 100% sure on what you meant by
Do you know in which places other than |
Essentially every place where we set
|
f02c083
to
41a689a
Compare
Since we're at it, could you bump to 7.1.1 so at least we avoid having to do another AGP bump shortly after? 👍 |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
41a689a
to
51b060c
Compare
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by @gabrieldonadel in 200488e. When will my fix make it into a release? | Upcoming Releases |
…cebook#33057) Summary: Upgrade Android Gradle to 7.1.0 on template and fix a bug where the bundle was not getting included when building the app in release mode Closes facebook#33002 Closes facebook#33018 Closes facebook#33046 Potentially fixes facebook#33029 ## Changelog [Android] [Changed] - Bump AGP to 7.1.0 and fix bundle inclusion in release mode Pull Request resolved: facebook#33057 Test Plan: 1. Run `./scripts/test-manual-e2e.sh` 2. Select `A new RN app using the template` and `Android` 3. Test app on the emulator 4. Open Android studio build the app using release variant 4. Check the release apk using Android studio "Analyze APK" tool and ensure the bundle is included ![image](https://user-images.githubusercontent.com/11707729/152700410-3bcb80b0-35b6-4bdc-bf57-98a42a29e5a6.png) Reviewed By: ShikaSD Differential Revision: D34076884 Pulled By: cortinico fbshipit-source-id: da4392af37e08e22dbcafba38476fd712141474a
…n startup This is a new incarnation of the same underlying React Native issue seen in 8f8a266 and 833d083, back in 2019 and 2018 respectively. RN hard-codes what intermediate directory it expects the Android Gradle Plugin to look for assets in; but that directory isn't any kind of stable API, and in fact it changes from time to time in new versions of AGP. It changed again in AGP 7.1.0. More recent versions of RN know about this latest change (with yet another hardcoding, conditioned on a new range of AGP versions): facebook/react-native#33057 But ours doesn't, because we haven't been updating RN for a while in this legacy codebase. So just update the directory we force it to. See discussion: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/release.20build.20missing.20JS.20bundle/near/1746718 [greg: expanded commit message]
Summary
Upgrade Android Gradle to 7.1.0 on template and fix a bug where the bundle was not getting included when building the app in release mode
Closes #33002
Closes #33018
Closes #33046
Potentially fixes #33029
Changelog
[Android] [Changed] - Bump AGP to 7.1.0 and fix bundle inclusion in release mode
Test Plan
./scripts/test-manual-e2e.sh
A new RN app using the template
andAndroid