Open scholzenius opened 3 years ago
You should delete the line inside sourceSets {} on build.gradle file
I have precisely the same problem.
I have precisely the same problem.
- NodeVersion: v14.16.0
- Platform: React Native on Windows
- Subsystem: nodejs-mobile-react-native Is there any solution?
have you try the solution above?
have you try the solution above?
I have no sourceSets config in app/build.gradle file.
Is there any working example with the latest version of "node-libs-react-native" (1.2.1) ?
re any working exam (I didn't find any working examples)
you need to open your project with android studio
you need to open your project with android studio
I have done it already.
you need to open your project with android studio
I have done it already.
then go to Gradle Scripts > build.gradle ( nodejs-mobile-reat-native) is around line 78
You need to have somthing like that,
sourceSets {
main {....}
main.assets.srcDirs += '../install/resources/nodejs-modules'
}
you need to delete de main bit, and the correct is like this:
sourceSets {
main.assets.srcDirs += '../install/resources/nodejs-modules'
}
I can confirm the following:
1) (the same as author) I followed these instructions:
https://code.janeasystems.com/nodejs-mobile/getting-started-react-native
2) (the same as author) I also tried the troubleshooting hints.
3) (the same as author) I have the same problem on Windows and Ubuntu Linux.
4) I opened your project android
with android studio
5) I have no "sourceSets" configs.
And even if I had sourceSets, I would not like this solution since I did not configure the sourceSets myself. So if it comes from the library, it should be patched in library.
And without any working example it's imposible to conclude that nodejs-mobile-react-native 1.2.1 is working at all in modern environment.
I can confirm the following:
- (the same as author) I followed these instructions: https://code.janeasystems.com/nodejs-mobile/getting-started-react-native
- (the same as author) I also tried the troubleshooting hints.
- (the same as author) I have the same problem on Windows and Ubuntu Linux.
- I opened your project
android
with android studio- I have no "sourceSets" configs. And even if I had sourceSets, I would not like this solution since I did not configure the sourceSets myself. So if it comes from the library, it should be patched in library. And without any working example it's imposible to conclude that nodejs-mobile-react-native 1.2.1 is working at all in modern environment.
I was having same issue Use reactnative --version 0.63 And add blacklist as mentioned in guide And also change `var EventEmitter = require('react-native/Libraries/vendor/emitter/EventEmitter'); To this import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter'; Refer this for change
it worked for me with 👍 1
android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zipdependencies {
classpath('com.android.tools.build:gradle:4.2.1')
as in https://developer.android.com/studio/releases/gradle-plugin#4-2-0.
"nodejs-mobile-react-native": "^0.6.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.63.4",
I have exactly the same Error and no answer work to me !!! Any soluation here ?!
@ghyath5 i suspect the metro.config.js
may be the issue, or watch out that sometimes nodejs-mobile android.gradle may be rewritten loosing the sourceSet hack.
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
module.exports = getDefaultConfig(__dirname);
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver: {
blacklistRE: blacklist([
/\/nodejs-assets\/.*/,
/\/android\/.*/,
/\/ios\/.*/
])
},
};
@sallespro
metro.config.js
file is fine and same as the code you provided above.
But android.gradle
has no sourceSet
block at all !!
https://github.com/anirudhmalik/imp-project/tree/Node_RN
Git clone this repo of mine..
@ghyath5 just make sure it's this file you're checking
<your project>/node_modules/nodejs-mobile-react-native/android/build.gradle
@sallespro
Thank you understand. It works perfectly!
@anirudhmalik tks for the reference project. i suggest you update :
gradle.properties
for android will ask for a gradle plugin update and it will cause OutOfMemory errors in gradle daemon.
org.gradle.jvmargs=-Xms2G -Xmx4g -XX:MaxPermSize=2g -XX:MaxMetaspaceSize=2g -Dkotlin.daemon.jvm.options="-Xmx1g"
@sallespro
Just tell me please why after I do your advices the app has been built successfully but when I run the app it crash if i has "node_modules" exist in nodejs-assets\nodejs-project\
@ghyath5 please provide the android studio debugger error message, Android logcat
to check exactly what might be wrong. The main reason is some module that has a native lib. ( .so) which in my experiments never worked.
@sallespro
I think as you said there was some native lib ... I am trying to run instagram-private-api
have you tried it before?
@ghyath5 it won't run. App crashes as soon as you npm install this module( instagram-private-api )and therefore I have built single js file to simulate login https://github.com/anirudhmalik/instagram-pvt-api
@anirudhmalik
Yes, I see. Thanks for your answer.
@sallespro I think as you said there was some native lib ... I am trying to run
instagram-private-api
have you tried it before?
i have not tried before instagram-private-api
, if there's no native dependency, it should work.
I have exactly the same problem
> Task :nodejs-mobile-react-native:mergeDebugNativeLibs FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Execution failed for task ':nodejs-mobile-react-native:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
> 2 files found with path 'lib/arm64-v8a/libnode.so' from inputs:
- /Users/<me>/projects/react-native/<my project>/node_modules/nodejs-mobile-react-native/android/build/intermediates/merged_jni_libs/debug/out/arm64-v8a/libnode.so
- /Users/<me>/Projects/react-native/<my project>/node_modules/nodejs-mobile-react-native/android/build/intermediates/cxx/Debug/4a1j5e35/obj/arm64-v8a/libnode.so
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
"react": "^17.0.2",
"react-native": "^0.66.3",
"nodejs-mobile-react-native": "^0.6.3",
Gradle version 7.0.2 Java version 11 NDK version 21.4.7075529 CMake version 3.18.1 Android SDK Platform 31 (12)
I tried these settings (and without) but nothing works
sourceSets {
main.assets.srcDirs += '../install/resources/nodejs-modules'
}
packagingOptions {
pickFirst 'lib/armeabi-v7a/libnode.so'
pickFirst 'lib/arm64-v8a/libnode.so'
pickFirst 'lib/x86/libnode.so'
pickFirst 'lib/x86_64/libnode.so'
}
@anirudhmalik
Hi Anirud,
Thanks for the suggestion but it did not work with "react": "0.63.4"
. I get the exact same error, unfortunately.
What did work though, with my initial setup, is adding the packagingOptions
to the file node_modules/nodejs-mobile-react-native/android/build.gradle
right after sourceSets
packagingOptions {
pickFirst 'lib/armeabi-v7a/libnode.so'
pickFirst 'lib/arm64-v8a/libnode.so'
pickFirst 'lib/x86_64/libnode.so'
pickFirst 'lib/x86/libnode.so'
}
It builds fine now and I can invoke the sample main.js app from react-native
hi, anyone knows if this library still working on recently versions of react-native?
📗 Problem
Description
I tried to use nodejs-mobile-react-native but got the following error:
Task :nodejs-mobile-react-native:mergeDebugNativeLibs FAILED 48 actionable tasks: 4 executed, 44 up-to-date
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':nodejs-mobile-react-native:mergeDebugNativeLibs'. A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction 2 files found with path 'lib/x86/libnode.so' from inputs:
I followed these instructions: https://code.janeasystems.com/nodejs-mobile/getting-started-react-native I also tried the troubleshooting hints. Can someone help?