diff --git a/packages/react-native-reanimated/android/build.gradle.kts b/packages/react-native-reanimated/android/build.gradle.kts index 7c57979bc64..ac36646ee7d 100644 --- a/packages/react-native-reanimated/android/build.gradle.kts +++ b/packages/react-native-reanimated/android/build.gradle.kts @@ -23,9 +23,13 @@ fun safeAppExtGet(prop: String, fallback: Any?): Any? { } fun resolveReactNativeDirectory(): File { - val reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null) as String? - if (reactNativeLocation != null) { - return file(reactNativeLocation) + val reactNativeLocationProperty = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null) + if (reactNativeLocationProperty != null) { + return when (reactNativeLocationProperty) { + is File -> reactNativeLocationProperty + is String -> file(reactNativeLocationProperty) + else -> file(reactNativeLocationProperty.toString()) + } } // Fallback to node resolver for custom directory structures like monorepos. diff --git a/packages/react-native-worklets/android/build.gradle.kts b/packages/react-native-worklets/android/build.gradle.kts index 2e01292a695..eddd7b816f7 100644 --- a/packages/react-native-worklets/android/build.gradle.kts +++ b/packages/react-native-worklets/android/build.gradle.kts @@ -23,9 +23,13 @@ fun safeAppExtGet(prop: String, fallback: Any?): Any? { } fun resolveReactNativeDirectory(): File { - val reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null) as String? - if (reactNativeLocation != null) { - return file(reactNativeLocation) + val reactNativeLocationProperty = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null) + if (reactNativeLocationProperty != null) { + return when (reactNativeLocationProperty) { + is File -> reactNativeLocationProperty + is String -> file(reactNativeLocationProperty) + else -> file(reactNativeLocationProperty.toString()) + } } // Fallback to node resolver for custom directory structures like monorepos.