Skip to content

Commit ef79980

Browse files
authored
feat(android): use node resolver to find react native package in monorepos (#735)
1 parent 394a3b2 commit ef79980

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

android/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ android {
5454
repositories {
5555
maven {
5656
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
57-
url "$rootDir/../node_modules/react-native/android"
57+
58+
// Use node resolver to locate react-native package
59+
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
60+
if (reactNativePackage.exists()) {
61+
url "$reactNativePackage.parentFile/android"
62+
}
63+
// Fallback to react-native package colocated in node_modules
64+
else {
65+
url "$rootDir/../node_modules/react-native/android"
66+
}
5867
}
5968
google()
6069
mavenLocal()

0 commit comments

Comments
 (0)