From 4d91f40fbdf0012689b04084113299676342c0dc Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 23 Mar 2022 04:50:12 -0700 Subject: [PATCH] Update template/android and RN Tester to use `hermes-engine` from the `react-native` NPM package. (#33467) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33467 We can now change the `hermes-engine` dependency to be consumed by the `react-native` NPM package and not anymore from the standalone `hermes-engine`. This will allow for a better stability as the `hermes-engine` and the `react-native` were built from source at the same instant in time. Changelog: [Android] [Changed] - Update template/android and RN Tester to use `hermes-engine` from the `react-native` NPM package. Reviewed By: hramos Differential Revision: D34213795 fbshipit-source-id: 29e54b37db0103f72e9983976ef9147fe69116e7 --- packages/rn-tester/android/app/build.gradle | 9 +++++---- template/android/app/build.gradle | 13 +++++++++---- template/android/settings.gradle | 2 ++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 739f1e2bb0d481..6100303bc10a57 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -226,11 +226,12 @@ dependencies { // Build React Native from source implementation project(':ReactAndroid') - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" + // Consume Hermes as built from source only for the Hermes variant. + hermesImplementation(project(":ReactAndroid:hermes-engine")) { + exclude group:'com.facebook.fbjni' + } - def hermesPath = '$projectDir/../../../../../node_modules/hermes-engine/android/' - hermesDebugImplementation files(hermesPath + "hermes-debug.aar") - hermesReleaseImplementation files(hermesPath + "hermes-release.aar") + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index a173c56b4e9897..2c96211af948fd 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -271,9 +271,10 @@ dependencies { } if (enableHermes) { - def hermesPath = "../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + //noinspection GradleDynamicVersion + implementation("com.facebook.react:hermes-engine:+") { // From node_modules + exclude group:'com.facebook.fbjni' + } } else { implementation jscFlavor } @@ -286,7 +287,11 @@ if (isNewArchitectureEnabled()) { configurations.all { resolutionStrategy.dependencySubstitution { substitute(module("com.facebook.react:react-native")) - .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source") + .using(project(":ReactAndroid")) + .because("On New Architecture we're building React Native from source") + substitute(module("com.facebook.react:hermes-engine")) + .using(project(":ReactAndroid:hermes-engine")) + .because("On New Architecture we're building Hermes from source") } } } diff --git a/template/android/settings.gradle b/template/android/settings.gradle index 2f93b7115036f3..bd838b9c306d59 100644 --- a/template/android/settings.gradle +++ b/template/android/settings.gradle @@ -6,4 +6,6 @@ includeBuild('../node_modules/react-native-gradle-plugin') if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { include(":ReactAndroid") project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') + include(":ReactAndroid:hermes-engine") + project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') }