Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): build error on monorepo #560

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Apr 10, 2024

Why

having the error when building on android with new architecture enabled and in a monorepo:

* What went wrong:
A problem occurred evaluating project ':react-native-picker_picker'.
> [react-native-picker] Unable to resolve react-native location in node_modules. You should add project extension property (in app/build.gradle) `REACT_NATIVE_NODE_MODULES_DIR` with path to react-native.

How

the line should be referenced from other libraries but since the current npm package name is namespaced under @react-native-picker/picker, we should add more ".."

Test Plan

#!/bin/bash

mkdir RN074Monorepo
cd RN074Monorepo
cat > package.json <<EOF
{
  "private": true,
  "workspaces": ["apps/*"]
}
EOF

mkdir apps
cd apps
npx @react-native-community/cli@latest init RN074 --version 0.74.0-rc.7 --skip-install
cd RN074
yarn add @react-native-picker/picker@2.7.2

# Fix react-native for monorepo
patch -p1 <<EOF
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -11,11 +11,11 @@ react {
     //   The root of your project, i.e. where "package.json" lives. Default is '..'
     // root = file("../")
     //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
-    // reactNativeDir = file("../node_modules/react-native")
+    reactNativeDir = file("../../../../node_modules/react-native")
     //   The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
-    // codegenDir = file("../node_modules/@react-native/codegen")
+    codegenDir = file("../../../../node_modules/@react-native/codegen")
     //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
-    // cliFile = file("../node_modules/react-native/cli.js")
+    cliFile = file("../../../../node_modules/react-native/cli.js")

     /* Variants */
     //   The list of variants to that are debuggable. For those we're going to
@@ -115,4 +115,4 @@ dependencies {
     }
 }

-apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
+apply from: file("../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,4 +1,4 @@
 rootProject.name = 'RN074'
-apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
+apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
 include ':app'
-includeBuild('../node_modules/@react-native/gradle-plugin')
+includeBuild('../../../node_modules/@react-native/gradle-plugin')
EOF

cd android
./gradlew -PnewArchEnabled=true :app:assembleDebug

Copy link
Contributor

@Naturalclar Naturalclar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, LGTM 🙏

@Naturalclar Naturalclar merged commit 827305b into react-native-picker:master Apr 10, 2024
2 of 12 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 10, 2024
## [2.7.5](v2.7.4...v2.7.5) (2024-04-10)

### Bug Fixes

* **android:** build error on monorepo ([#560](#560)) ([827305b](827305b))
@Naturalclar
Copy link
Contributor

🎉 This PR is included in version 2.7.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Kudo Kudo deleted the patch-1 branch April 10, 2024 08:11
@Kudo
Copy link
Contributor Author

Kudo commented Apr 10, 2024

thanks @Naturalclar for the quick deployment.

Kudo added a commit to expo/expo that referenced this pull request Apr 10, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
tsapeta pushed a commit to expo/expo that referenced this pull request Apr 11, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
tsapeta pushed a commit to expo/expo that referenced this pull request Apr 12, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
alanjhughes pushed a commit to expo/expo that referenced this pull request Apr 16, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
brentvatne pushed a commit to expo/expo that referenced this pull request Apr 17, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
tsapeta pushed a commit to expo/expo that referenced this pull request Apr 17, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
alanjhughes pushed a commit to expo/expo that referenced this pull request Apr 17, 2024
# Why

fix bridgeless support on android

# How

1. set `newArchEnabled=true` on bare-expo
2. disable expo-updates which is blocked by #27996 
3. patch @react-native-picker/picker which has a build error:
react-native-picker/picker#560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants