Skip to content

Commit e695bc0

Browse files
cortinicofacebook-github-bot
authored andcommitted
Set a resolution strategy for com.facebook.react:react-native when on New Architecture. (#33134)
Summary: Pull Request resolved: #33134 When a user is enabling New Architecture, we should make sure they don't accidentally mix imports of React Native from source vs prebuilts. With this resolution strategy, we'll make sure all the import of `com.facebook.react:react-native:+` will be resolved to the correct dependency. Changelog: [Android] [Fixed] - Set a resolution strategy for com.facebook.react:react-native when on New Architecture Reviewed By: ShikaSD Differential Revision: D34303267 fbshipit-source-id: 492fec59175c5887571e1b09ca8e233584b45dd1
1 parent 2db1bca commit e695bc0

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

template/android/app/build.gradle

+14-8
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,8 @@ android {
238238
dependencies {
239239
implementation fileTree(dir: "libs", include: ["*.jar"])
240240

241-
// If new architecture is enabled, we let you build RN from source
242-
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
243-
if (isNewArchitectureEnabled()) {
244-
implementation project(":ReactAndroid")
245-
} else {
246-
//noinspection GradleDynamicVersion
247-
implementation "com.facebook.react:react-native:+" // From node_modules
248-
}
241+
//noinspection GradleDynamicVersion
242+
implementation "com.facebook.react:react-native:+" // From node_modules
249243

250244
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
251245

@@ -271,6 +265,18 @@ dependencies {
271265
}
272266
}
273267

268+
if (isNewArchitectureEnabled()) {
269+
// If new architecture is enabled, we let you build RN from source
270+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
271+
// This will be applied to all the imported transtitive dependency.
272+
configurations.all {
273+
resolutionStrategy.dependencySubstitution {
274+
substitute(module("com.facebook.react:react-native"))
275+
.using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
276+
}
277+
}
278+
}
279+
274280
// Run this once to be able to run the application with BUCK
275281
// puts all compile dependencies into folder libs for BUCK to use
276282
task copyDownloadableDepsToLibs(type: Copy) {

0 commit comments

Comments
 (0)