diff --git a/packages/helloworld/android/app/build.gradle b/packages/helloworld/android/app/build.gradle index 557a871cce..bc4df63bfb 100644 --- a/packages/helloworld/android/app/build.gradle +++ b/packages/helloworld/android/app/build.gradle @@ -23,7 +23,7 @@ react { // The folder where the react-native NPM package is. Default is ../node_modules/react-native reactNativeDir = file("../../../react-native") // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen - codegenDir = file("../../../react-native-codegen") + codegenDir = file("$rootDir/node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js, // but now points to our simplified bundle wrapper. cliFile = file("../../scripts/bundle.js") diff --git a/packages/helloworld/android/settings.gradle b/packages/helloworld/android/settings.gradle index e80fcd06cf..6da9a43763 100644 --- a/packages/helloworld/android/settings.gradle +++ b/packages/helloworld/android/settings.gradle @@ -6,10 +6,18 @@ */ // Autolinking has now moved into the React Native Gradle Plugin -pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } +pluginManagement { includeBuild("../../react-native-gradle-plugin") } plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } rootProject.name = 'HelloWorld' include ':app' includeBuild('../../react-native-gradle-plugin') +includeBuild('../../react-native') { + dependencySubstitution { + substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid")) + substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid")) + substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine")) + substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine")) + } + } diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index c1598daa13..76d41a679a 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -794,7 +794,15 @@ react { // module to apply the plugin to, so it's codegenDir and reactNativeDir won't be evaluated. if (rootProject.name == "react-native-build-from-source") { rootProject.extensions.getByType(PrivateReactExtension::class.java).apply { - codegenDir = file("$rootDir/../@react-native/codegen") + // We try to guess where codegen lives. Generally is inside + // node_modules/@react-native/codegen. If the file is not existing, we + // fallback to ../react-native-codegen (used for hello-world app). + codegenDir = + if (file("$rootDir/../@react-native/codegen").exists()) { + file("$rootDir/../@react-native/codegen") + } else { + file("$rootDir/../react-native-codegen") + } reactNativeDir = file("$rootDir") } } diff --git a/packages/react-native/build.gradle.kts b/packages/react-native/build.gradle.kts index 5d7f54b975..2667e535a5 100644 --- a/packages/react-native/build.gradle.kts +++ b/packages/react-native/build.gradle.kts @@ -16,3 +16,5 @@ plugins { alias(libs.plugins.download) apply false alias(libs.plugins.kotlin.android) apply false } + +buildscript { dependencies { classpath("com.facebook.react:react-native-gradle-plugin") } }