-
Notifications
You must be signed in to change notification settings - Fork 25k
android: Ensure we use the local Maven repo to get react-native #35208
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
Conversation
This fixes facebook#35204. It ensures that for getting the Android binary dependencies provided by React Native, the build always looks only in the local Maven repo inside node_modules/react-native/. Without this, the build also looks in the other configured repositories like Maven Central. Those sometimes have RN binaries in them, by mistake or otherwise, which may be the wrong version. For how this snippet works, see Gradle documentation: https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-content-filtering Thanks to inckie for pointing out this feature: facebook#35204 (comment)
This fixes a build failure which started happening today due to an operational mistake in React Native release management: facebook/react-native#35204 Happily Gradle gives us a way to more precisely pin down what we want it to do when finding dependencies, which makes the build robust to this and any similar issue. I've sent the same fix upstream for the template app: facebook/react-native#35208 See also where we spotted the issue in CI: zulip#5524 (comment) and discussion in chat: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/build.20failure.3A.20libfbjni.2Eso.20duplicated/near/1459787
Base commit: f0b7cbe |
Base commit: f0b7cbe |
|
PR build artifact for c5c32cb is ready. |
|
@cortinico + @brentvatne you may both be interested in this - it came from the collaboration on the github issue related to the android build break today |
|
CI is failing. It looks like the issue is that the CI job relies on passing an extra Gradle property Then the way that property is given meaning is this bit in the RN Gradle plugin, in fun configureRepositories(project: Project, reactNativeDir: File) {
with(project) {
if (hasProperty("REACT_NATIVE_MAVEN_LOCAL_REPO")) {
mavenRepoFromUrl("file://${property("REACT_NATIVE_MAVEN_LOCAL_REPO")}")
}That is, when the property is present, the plugin configures an additional Maven repo based on it. That gets defeated when there's already an I think it should be straightforward to fix things so that this fix for #35204 works without interfering with the use of the Perhaps better: it seems like that code in the RN Gradle plugin is already doing a job that overlaps with that code in the template To be explicit for anyone seeing this thread while looking for a workaround to #35204: the fix in this PR is still a good one to apply to individual apps (even before the further wrinkles I intend to add to it.) The case where it doesn't work is if you're passing a Gradle property |
|
Hey @gnprice This change as it is, it's actually unnecessary as it will land on main (so wilk be shipped on 0.72). You should send this same PR agains the 0.68-stable, 0.69-stable and 0.70-stable. 0.71 is instead unaffected as it will consume artifacts from Maven Central. That's also the reason why the CI is red. |
|
Closing for the aforemntioned reasons + we provided hotfixes for the last 8 stable releases |
Ah, and I see the explanation that's now on #35210:
That's great news! Glad this is already fixed thoroughly in main, and thanks for providing those stable-version fixes. |
Summary
This fixes #35204. It ensures that for getting the Android binary dependencies provided by React Native, the build always looks only in the local Maven repo inside node_modules/react-native/.
Without this, the build also looks in the other configured repositories like Maven Central. Those sometimes have RN binaries in them, by mistake or otherwise, which may be the wrong version.
For how this snippet works, see Gradle documentation:
https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:repository-content-filtering
Thanks to inckie for pointing out this feature:
#35204 (comment)
Changelog
[Android] [Fixed] - Always get React Native Android libraries from node_modules
Test Plan
I applied this change to my own project where #35204 was reproducing, and the build started succeeding again.