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

🐛 [Android] - Does not build within monorepo #340

Closed
3 of 4 tasks
batical opened this issue Aug 6, 2021 · 12 comments · Fixed by #1466
Closed
3 of 4 tasks

🐛 [Android] - Does not build within monorepo #340

batical opened this issue Aug 6, 2021 · 12 comments · Fixed by #1466
Labels
🤖 android Issue affects the Android platform 🐛 bug Something isn't working 📢 help wanted Extra attention is needed

Comments

@batical
Copy link

batical commented Aug 6, 2021

What were you trying to do?

Trying to build on android with a Monorepo with version 2.5.0

Previous version was working fine

What happened instead?

Where:
Build file '[...]/node_modules/react-native-vision-camera/android/build.gradle' line: 220

* What went wrong:
A problem occurred evaluating project ':react-native-vision-camera'.
> Expected directory '[...]/packages/mobile/android/../node_modules/react-native/android' to contain exactly one file, however, it contains no files.

I changed the path on :
line 220, 221, 223, 229

but got C compilation error
fatal error: 'jsi/jsi.h' file not found

after updating l97 the build command is working

Relevant log output

No response

Device

Android

VisionCamera Version

2.5.0

Additional information

@batical batical added the 🐛 bug Something isn't working label Aug 6, 2021
@mrousavy
Copy link
Owner

mrousavy commented Aug 6, 2021

Interesting, does this work if you create a symlink to node_modules in the mobile/ directory?

@batical
Copy link
Author

batical commented Aug 7, 2021

I will try to give a try next week. (for now I created a patch-package for my case).

@mrousavy mrousavy added the 🤖 android Issue affects the Android platform label Aug 18, 2021
@zifahm
Copy link

zifahm commented Aug 20, 2021

@batical what did you fix on patch package?

@mrousavy mrousavy added the 📢 help wanted Extra attention is needed label Aug 25, 2021
@batical
Copy link
Author

batical commented Aug 26, 2021

Here is the content on my patch package

diff --git a/node_modules/react-native-vision-camera/android/build.gradle b/node_modules/react-native-vision-camera/android/build.gradle
index 7c74d37..1b66ee2 100644
--- a/node_modules/react-native-vision-camera/android/build.gradle
+++ b/node_modules/react-native-vision-camera/android/build.gradle
@@ -94,7 +94,7 @@ android {
         cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
         abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
         arguments '-DANDROID_STL=c++_shared',
-                "-DNODE_MODULES_DIR=${rootDir}/../node_modules",
+                "-DNODE_MODULES_DIR=${rootDir}/../../../node_modules",
                 "-DFOR_HERMES=${FOR_HERMES}"
       }
     }
@@ -217,16 +217,16 @@ dependencies {
   //noinspection GradleDynamicVersion
   extractJNI("com.facebook.fbjni:fbjni:+")
 
-  def rnAAR = fileTree("${rootDir}/../node_modules/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile
-  def jscAAR = fileTree("${rootDir}/../node_modules/jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
+  def rnAAR = fileTree("${rootDir}/../../../node_modules/react-native/android").matching({ it.include "**/**/*.aar" }).singleFile
+  def jscAAR = fileTree("${rootDir}/../../../node_modules/jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
 
-  def inputFile = new File(rootDir, '../node_modules/react-native/package.json')
+  def inputFile = new File(rootDir, '../../../node_modules/react-native/package.json')
   def json = new JsonSlurper().parseText(inputFile.text)
   def reactNativeVersion = json.version as String
   def (major, minor, patch) = reactNativeVersion.tokenize('.')
 
   def jsEngine = FOR_HERMES ? "hermes" : "jsc"
-  def reaAAR = "${rootDir}/../node_modules/react-native-reanimated/android/react-native-reanimated-${minor}-${jsEngine}.aar"
+  def reaAAR = "${rootDir}/../../../node_modules/react-native-reanimated/android/react-native-reanimated-${minor}-${jsEngine}.aar"
 
   extractJNI(files(rnAAR, jscAAR, reaAAR))
 
@@ -274,7 +274,7 @@ task extractJNIFiles {
 
 def downloadsDir = new File("$buildDir/downloads")
 def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
-def thirdPartyVersionsFile = new File("${rootDir}/../node_modules/react-native/ReactAndroid/gradle.properties")
+def thirdPartyVersionsFile = new File("${rootDir}/../../../node_modules/react-native/ReactAndroid/gradle.properties")
 def thirdPartyVersions = new Properties()
 thirdPartyVersions.load(new FileInputStream(thirdPartyVersionsFile))

@zifahm
Copy link

zifahm commented Sep 1, 2021

@batical thanks 👍

@batical
Copy link
Author

batical commented Sep 1, 2021

working also with last versions 2.6.1 in debug or release mode

@hirbod
Copy link
Contributor

hirbod commented Dec 18, 2021

@mrousavy I've encountered the same issue right now while trying to install it in my monorepo setup. iOS is working flawlessly.
Maybe this one is helpful for you: https://github.com/software-mansion/react-native-gesture-handler/pull/1757/files

This is how react-native-gesture-handler fixed that issue for monorepos when trying to determine react-native-reanimated version

@Alexispap
Copy link
Sponsor

Alexispap commented Jul 1, 2022

I encountered this at RN 0.69.1 and solved it temporarily by replacing line 228 in the android/build.gradle file of react-native-vision-camera (in node_modules) by
def rnAAR = fileTree("${nodeModules}/react-native/android/com/facebook/react/react-native/0.69.1").matching({ it.include "**/**/*-release.aar" }).singleFile
Here, the word release could also be exchanged by debug, i guess.
Beware, that every reinstall of node_modules will wipe this change from the file.

@mrozkosz
Copy link

mrozkosz commented Jul 5, 2022

I have the same problem and still not resolved @mrousavy

@hirbod
Copy link
Contributor

hirbod commented Jul 5, 2022

Not sure what you are doing, but I have a monorepo setup (0.68.2) and it's working fine

@mrozkosz
Copy link

mrozkosz commented Jul 5, 2022

As you can see when I build the application I get this error.

Zrzut ekranu 2022-07-5 o 20 18 19

Zrzut ekranu 2022-07-5 o 20 22 14

"react-native-vision-camera": "^2.13.5",
"react-native-reanimated": "^2.9.1"
"react-native": "0.69.1",

java version "16.0.1"

What is the problem? @hirbod, without react-native-reanimated I can build the application, but I need this...

@hirbod
Copy link
Contributor

hirbod commented Jul 5, 2022

I don't know. And I am not sure why you Tag so many random people which aren't even involved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Issue affects the Android platform 🐛 bug Something isn't working 📢 help wanted Extra attention is needed
Projects
None yet
6 participants