Skip to content

Commit

Permalink
feat(android): use node resolver to find react native package in mono…
Browse files Browse the repository at this point in the history
…repos (#735)
  • Loading branch information
morganick authored Sep 12, 2024
1 parent 394a3b2 commit ef79980
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ android {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"

// Use node resolver to locate react-native package
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
if (reactNativePackage.exists()) {
url "$reactNativePackage.parentFile/android"
}
// Fallback to react-native package colocated in node_modules
else {
url "$rootDir/../node_modules/react-native/android"
}
}
google()
mavenLocal()
Expand Down

0 comments on commit ef79980

Please sign in to comment.