You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm receiving a value in a buffer(2) and I used the readInt16BE() to read It as integer.
for example:
console.log(buf); //Buffer<00 02>
console.log(buf.readInt16BE()); // 2
but when I'm trying to send it to react-native side the received value will be:
alert("from node:"+msg);// from node:0
I've tried many convert ways, Like: "toString(),ParseInt(),and also Number()", but it doesn't work.
is the problem from the way to convert the buffer or the technique in sending it?
That was very helpful, my problem is solved.
Actually, I am on windows.
I am sorry for asking another question but I've recently had a problem in creating a new project, although it was work in the past, I was following the steps below:
Create a new RN app react-native init TestProject
(or you may try $ create-react-native-app if there could be a difference)
cd TestProject
Run react-native run-android to test and -------------->it works successfully.<--------------------
npm install nodejs-mobile-react-native --save
react-native link nodejs-mobile-react-native
Go to nodejs-assets/nodejs-project/ path and rename sample-main.js to main.js and sample-package.json to package.json
Create a rn-cli.config.js that contains :
================================================================== const blacklist = require('metro-config/src/defaults/blacklist'); module.exports = { resolver:{ blacklistRE: blacklist([ /nodejs-assets\/.*/, /android\/.*/, /ios\/.*/ ]) }, };
===============================================================
I also tried on virtual mac but the same error
what's wrong?
What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
More than one file was found with OS independent path 'lib/x86/libc++_shared.so'
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.
BUILD FAILED in 2m 41s
45 actionable tasks: 34 executed, 11 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug
`
Hope that describes the error, sorry for my lack of knowledge.
I have to mention that in each project I created, it gave me an error in the trace, but I was able to solve it with the help of android studio and to replace the " / " with " \ ".
but now Android studio doesn't show me that error again.
and shows 4 errors, the following image shows the first error: can not resolve symbol 'gradle'
Regarding the More than one file was found with OS independent path 'lib/x86/libc++_shared.so' error you were getting, I'm getting it as well in other OSes.
The newer releases of react-native use libc++_shared.so as the APP_STL, the same as nodejs-mobile and the build system is not able to know which one it should pick.
I'm currently trying to see if there's something I might be able to do inside the plugin to fix it, but from the application side you can tell gradle to pick the first it finds, since they'll be the same. Inside android/app/build.gradle add the following packagingOptions block inside the android block:
This error is caused by hasteImpl returning the same name for different files.
at setModule (D:\NodeJs_Application\Private\TestProject\node_modules\metro\node_modules\jest-haste-map\build\index.js:569:17)
at workerReply (D:\NodeJs_Application\Private\TestProject\node_modules\metro\node_modules\jest-haste-map\build\index.js:641:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1468) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:1468) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`
And I meant in the "trace" issue is that when I add any plugin, for somehow the URL was added wrongly in the file settings. gradle and I just corrected by replacing "/ " with " \ ". But it disappears now.
Here:
Thanks! that solved my problem. ^_^
for settings.gradle it was happening for all plugins, so as you said it not your issue.
I appreciate your efforts, thank you so much.
Activity
jaimecbernardo commentedon Mar 21, 2019
Hi, haven't tried passing a Buffer yet.
What platform are you on? In the react-native plugin, what is sent will be converted to JSON and back when it is passed through the bridge.
This article might be helpful in understanding what happens to a Buffer when converted to JSON: https://hackernoon.com/https-medium-com-amanhimself-converting-a-buffer-to-json-and-utf8-strings-in-nodejs-2150b1e3de57
Hope this is helpful.
WijdanMTak commentedon Apr 2, 2019
That was very helpful, my problem is solved.
Actually, I am on windows.
I am sorry for asking another question but I've recently had a problem in creating a new project, although it was work in the past, I was following the steps below:
Create a new RN app
react-native init TestProject(or you may try
$ create-react-native-appif there could be a difference)cd TestProjectRun
react-native run-androidto test and -------------->it works successfully.<--------------------npm install nodejs-mobile-react-native --savereact-native link nodejs-mobile-react-nativeGo to
nodejs-assets/nodejs-project/path and renamesample-main.jstomain.jsandsample-package.jsontopackage.jsonCreate a
rn-cli.config.jsthat contains :==================================================================
const blacklist = require('metro-config/src/defaults/blacklist'); module.exports = { resolver:{ blacklistRE: blacklist([ /nodejs-assets\/.*/, /android\/.*/, /ios\/.*/ ]) }, };===============================================================
I also tried on virtual mac but the same error
what's wrong?
jaimecbernardo commentedon Apr 2, 2019
Hi @WijdanMTak ,
What error message are you getting?
WijdanMTak commentedon Apr 3, 2019
`[3/3] Linking CXX shared library ........\build\intermediates\cmake\debug\obj
armeabi-v7a\libnodejs-mobile-react-native-native-lib.so
FAILURE: Build failed with an exception.
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
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.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 41s
45 actionable tasks: 34 executed, 11 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug
`
Hope that describes the error, sorry for my lack of knowledge.
WijdanMTak commentedon Apr 3, 2019
I have to mention that in each project I created, it gave me an error in the trace, but I was able to solve it with the help of android studio and to replace the " / " with " \ ".

but now Android studio doesn't show me that error again.
and shows 4 errors, the following image shows the first error:
can not resolve symbol 'gradle'jaimecbernardo commentedon Apr 3, 2019
Hi @WijdanMTak ,
Regarding the
More than one file was found with OS independent path 'lib/x86/libc++_shared.so'error you were getting, I'm getting it as well in other OSes.The newer releases of react-native use
libc++_shared.soas theAPP_STL, the same asnodejs-mobileand the build system is not able to know which one it should pick.I'm currently trying to see if there's something I might be able to do inside the plugin to fix it, but from the application side you can tell gradle to pick the first it finds, since they'll be the same. Inside
android/app/build.gradleadd the followingpackagingOptionsblock inside theandroidblock:Regarding the trace error, what are you talking about?
WijdanMTak commentedon Apr 4, 2019
Thanks for your response,but unfortunately, that doesn't solve the problem and leads to the previous error (Duplicate module name Error):
what should I do?
WijdanMTak commentedon Apr 4, 2019
And I meant in the "trace" issue is that when I add any plugin, for somehow the URL was added wrongly in the file

settings. gradleand I just corrected by replacing "/ " with " \ ". But it disappears now.Here:
jaimecbernardo commentedon Apr 4, 2019
The duplicate module name issue can be solved by following these steps from the
README.md: https://github.com/janeasystems/nodejs-mobile-react-native/tree/022c47e67f298d89170aea8e7b5e31103f433ebb#duplicate-module-nameThe newest versions of
react-nativeseem to add ametro.config.jsfile where the contents have to be put instead.Regarding the
settings.gradle, that's managed by thereact-native-cli. Was it happening for thenodejs-mobile-react-nativeplugin only?WijdanMTak commentedon Apr 10, 2019
Thanks! that solved my problem. ^_^
for
settings.gradleit was happening for all plugins, so as you said it not your issue.I appreciate your efforts, thank you so much.