Open Bishalsahoo opened 6 years ago
Hi @Bishalsahoo ,
I've been unable to reproduce this error. It ran on a arm64 Android 7.0 device.
I've tried to reproduce it and the leveldown
version inside pouchdb
from running npm install express pouchdb express-pouchdb
is 3.0.0, which means it didn't compile until I've applied the patch mentioned here: https://github.com/janeasystems/nodejs-mobile-module-compat/issues/1#issuecomment-402518031
At runtime, some modules seem to expect the current working directory to be a writable directory to save some temporary lock and log files, so I've also had to change the current working directory with process.chdir
. A better solution is to search how to configure the modules to use another location other that the current working directory, since changing it might have unusual effects on Android.
Did your project compile without applying the leveldown patch? If so, it might be skipping native modules compilation. Also, your module seems to be inside nodejs-mobile-cordova-assets/builtin_modules/leveldown/
, which is unusual.
Please provide more information or a repo with your project, since the runtime path for loading leveldown is unusual.
Sorry for the late reply , the basic of my main project is to be able to sync data seemlessly among different devices running my Cordova Android or iOS app with the help of nodejs server running in the backend . So I started with the pouch Todo example along with express pouch server in the backend . When I am trying to install the dependencies for the same like express express pouchdb memdown ..... in the nodejs project folder it is unable to find the modules , even after mentioning in the .dir file . So I just tried to move it to the folder where the Cordova bridge module exists and it worked fine as long as I am using memdown for the pouchdb ie storing data in the memory for the server. But when I tried to store the same data through the code I mentioned above it shows error in the Cordova nodejs plugin as mentioned above (even though my app works perfectly and stores data in the local storage for the front end but for server it shows the error in the Android studio and even in the data base of the server when I am accessing it through the browser. This above server code works perfectly fine on my browser as client and running the server in the terminal . As you mentioned it works fine without any error , can you please be able to provide me the sample of the same so that I can go through it and see why am I facing the issue . It will be a great help . Thank you
Hi @mavericksthinker , Check the Cordova Native Modules Sample, in the samples repo: https://github.com/janeasystems/nodejs-mobile-samples/tree/dd008acf75f3202ee4ab64b3822ab4bfa6e6f965/cordova/UseNativeModules
I think that's the most useful sample to help you understand the structure of the project and using native modules.
Yes I have gone through that example and started building this project . I have tried that workaround and still the build fails.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mergeDebugAssets'.
> unable to create new native thread
*Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 20m 4s
at ChildProcess.whenDone
(/home/hottab/Documents/CordovaApps/testApp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:915:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:14387) 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: 1)
(node:14387) [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.
Here is the small example that will reproduce the same error Repo
Steps used to create the project: 1.cordova create testApp 2.cd testApp 3.cordova platform add android@6(6.4.0) 4.cordova plugin add nodejs-mobile-cordova 5.cordova plugin add cordova-plugin-console 6.configure the nodejs-project files along with index.js 7.npm install pouchdb express express-pouchdb
Please If you can provide a workaround/suggestion that will be a great help. Another question , I am unable to make the node module start on android version@5,6.0.1. It only worked on android@7(Nougat) . Is there a way to make the node start on the other versions of the android mentioned above.
Hi @Bishalsahoo ,
I've just tried building from your repo, and was able to cordova build android
successfully.
This might be some difference in build machine configuration.
You can try to get more information running gradle as suggested in the error you get:
cd platforms/android
./gradlew assembleDebug --stacktrace
(You can try with the --info
or --debug
as well)
Regarding the android versions, I'm suspecting you are using a simulator, which contain older versions of WebView. This issue might be helpful: https://github.com/janeasystems/nodejs-mobile/issues/119#issuecomment-421920409
Thank you I was able to solve the problem by applying the workaround , but is it possible to use Cordova plugin file on the nodejs side? So that we can change the directory to store the data on android. One more thing is the app that I build with the same has huge amount of data stored in the app even though no data is actually stored ,why that happens?
Hi @mavericksthinker.
It's not possible to use cordova plugins on the nodejs side. You should use the channel to make the calls you need.
For storing the data, you can pass the paths from Cordova to node or use this API: https://github.com/janeasystems/nodejs-mobile-cordova/tree/be459ac4702a825a9254be03fc9448a5487436db#cordovaappdatadir
Node expects to run the project from a file system, so the project is copied to files, as specified in the README: https://github.com/janeasystems/nodejs-mobile-cordova/tree/be459ac4702a825a9254be03fc9448a5487436db#node-modules
On Android, the plugin extracts the project files and the Node modules from the APK assets in order to make them available to the Node.js for Mobile Apps engine. They are extracted from the APK and copied to a working folder (context.getFilesDir().getAbsolutePath() + "/www/nodejs-project/") when the application is launched for the first time or a new version of the application has been installed.
Hello @jaimecbernardo, thank you for the response . I actually was able to build the app by changing the version of gradle as I was getting new thread can be created on gradle 4.4. But can you specify which version of gradle were you using for the build? And another question I kept all the required node modules in the nodejs_project and the build was completed but when I ran it even though modules like express express-Pouchdb ,corser were installed still it throws err module can be found . I checked the build folder and all the modules are present but I am unaware why this error is produced . Can you help me with this please?
Hi @mavericksthinker ,
I have Gradle '4.6.0' installed in the system but the Cordova project in the Native Module Samples should be using a Gradle Wrapper for '4.1', according to the used cordova-android 6.4.0
release: https://github.com/apache/cordova-android/blob/rel/6.4.0/bin/templates/project/build.gradle#L50
This can be verified by running ./gradlew --version
inside platforms/android/
.
Regarding the error you mention, it sounds like it's a project or module specific issue. Do you have a log of the exact error you're getting with a replication repo and instructions on how to replicate that could be looked into? Starting with the cordova/UseNativeModules/
sample as a base for the replication would be a way to do it.
Hello @jaimecbernardo , thank you for your response. Yes I will try to provide you the error log or a sample report that provides the same error. Just wanted to ask is there a way to make the server running on the nodejs module to work in background like whatsapp notification services so that the server will be on once the phone boots or is on ?
Hello @jaimecbernardo , I have an issue with building the node_modules . I am getting following error while running the cordova build
make: *** [Release/obj.target/node_sqlite3.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/Documents/Cordovaapps/apps/node_modules/nodejs-mobile-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.15.0-42-generic
gyp ERR! command "/home/.nvm/versions/node/v8.12.0/bin/node" "/home/Documents/Cordovaapps/apps/node_modules/nodejs-mobile-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/Documents/Cordovaapps/apps/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/sqlite3/lib/binding/node_abi-platform-arch/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/Documents/Cordovaapps/apps/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/sqlite3/lib/binding/node_abi-platform-arch"
gyp ERR! cwd /home/Documents/Cordovaapps/apps/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/sqlite3
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v0.2.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/home/.nvm/versions/node/v8.12.0/bin/node /home/Documents/Cordovaapps/apps/platforms/android/../../node_modules/nodejs-mobile-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/Documents/Cordovaapps/apps/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/sqlite3/lib/binding/node_abi-platform-arch/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/Documents/Cordovaapps/apps/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project/node_modules/sqlite3/lib/binding/node_abi-platform-arch' (1)
node-pre-gyp ERR! stack at ChildProcess.node-pre-gyp install --fallback-to-build
npm verb stack Exit status 1
npm verb stack at EventEmitter.node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@3.1.13 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 83092ms
npm ERR! A complete log of this run can be found in: npm ERR! /home/.npm/_logs/2018-12-13T07_30_38_379Z-debug.log
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':BuildNpmModulesarmeabi-v7a'.
Process 'command 'npm'' finished with non-zero exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 4m 12s
The sqlite3 Module is not building . I am using
"dependencies": { "corser": "^2.0.1", "express": "4.15.3", "express-pouchdb": "^2.3.7", "pouchdb-adapter-http": "^6.2.0", "pouchdb-adapter-node-websql": "6.2.0", "pouchdb-core": "6.2.0", "pouchdb-mapreduce": "6.2.0", "pouchdb-replication": "6.2.0" }
these dependencies . Please can you give any suggestion how to fix this my cordova is 7.1.0 also tried on 8.1.2 ,node is 8.12.0, npm is 6.5.0 android 6.4 , gradle 4.1,ndk 17 as I am having problem with ndk 18 due to lack of the folder in toolchain.
Hi @mavericksthinker ,
For having it run in the background once the phone turns on I think you'd probably have to hook up the native library as an Android service, or having the Application start as the phone starts but you'd have to check how to do that for Cordova Apps if it's possible (or general Apps). Either way, once the App is started it can be expected to keep running in the background since the nodejs-mobile engine is running native code, according to the Android docs: https://developer.android.com/training/articles/perf-jni These are more general Android questions, so this is not the best place to get them answered.
Regarding the error, I don't seem to notice what is occurring, from the logs provided. Have you been able to build the sample repo linked earlier? It uses sqlite3, as well.
Hi @algorist-mechanism , @jaimecbernardo ,
I try pouchdb version 7.0.0 and I have the same issue:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: dlopen failed: cannot locate symbol "napi_create_external" referenced by "/data/data/com.yourorg.sample/files/nodejs-project/node_modules/pouchdb/node_modules/leveldown/prebuilds/android-arm/node-napi.node"...
Have you solved this problem? Thanks
Hi @bavuvanet, I'll answer in https://github.com/janeasystems/nodejs-mobile/issues/159, where this comment is duplicated.
Hello , I have been working on a project where I creating a express-pouchdb server Here is the sample
But I am getting following error
Can anyone please help to solve this problem of using 64bit or any alternatives to this? Thank you in advance.