diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index 506dca121113d4..bb24740f14a052 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -238,14 +238,8 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - // If new architecture is enabled, we let you build RN from source - // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. - if (isNewArchitectureEnabled()) { - implementation project(":ReactAndroid") - } else { - //noinspection GradleDynamicVersion - implementation "com.facebook.react:react-native:+" // From node_modules - } + //noinspection GradleDynamicVersion + implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" @@ -271,6 +265,18 @@ dependencies { } } +if (isNewArchitectureEnabled()) { + // If new architecture is enabled, we let you build RN from source + // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. + // This will be applied to all the imported transtitive dependency. + 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") + } + } +} + // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) {