react-native-vision-camera
react-native-vision-camera copied to clipboard
🐛 [Android] - Does not build within monorepo
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
- [ ] I am using Expo
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
Interesting, does this work if you create a symlink to node_modules
in the mobile/
directory?
I will try to give a try next week. (for now I created a patch-package for my case).
@batical what did you fix on patch package?
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))
@batical thanks :+1:
working also with last versions 2.6.1 in debug or release mode
@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
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.
I have the same problem and still not resolved @mrousavy
Not sure what you are doing, but I have a monorepo setup (0.68.2) and it's working fine
As you can see when I build the application I get this error.
"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...
I don't know. And I am not sure why you Tag so many random people which aren't even involved