Open wtchaos opened 5 years ago
Hi @wtchaos ,
Have you looked at the sample that uses a node project folder? https://github.com/janeasystems/nodejs-mobile-samples/tree/1eb9c4c0f1e02b009ca55bc610cc9e8cda403afa/android/native-gradle-node-folder Or in the website? https://code.janeasystems.com/nodejs-mobile/android/node-project-folder#add-a-npm-module-to-the-nodejs-project
The "Resources for Newcomers" is a good place to start: https://github.com/janeasystems/nodejs-mobile/tree/2a0a302aa614ff966176f412756836b68e020ce2#resources-for-newcomers
Thanks @jaimecbernardo Yes, I have looked at the sample and the description in the website. It says "by running npm install {module_name} inside nodejs-project". Does it mean execute the command in the windows system, or MacOs, or Linux? But I want to execute "npm install" in the android system.Or am I getting it wrong?
Hi @wtchaos ,
Yes, it's in the development machine that you must run npm install, so that the module is embedded in the APK and accessible at runtime.
In the sample README, the instructions are to run the command in a development folder (android/native-gradle-node-folder/app/src/main/assets/nodejs-project/
) :
https://github.com/janeasystems/nodejs-mobile-samples/tree/1eb9c4c0f1e02b009ca55bc610cc9e8cda403afa/android/native-gradle-node-folder#how-to-run
https://github.com/janeasystems/nodejs-mobile-samples/tree/1eb9c4c0f1e02b009ca55bc610cc9e8cda403afa/android/native-gradle-node-folder#add-an-npm-module-to-the-nodejs-project
Thanks for your reply @jaimecbernardo But sometimes, library needs compile in the production environment, like sqlite3. Perhaps,could you tell me how can I embed the sqlit3 into the nodejs-mobile?Thanks.
@wtchaos I'm guessing in the case of sqlite3
it needs to be cross compiled for your target android system.
Hi @ralphtheninja It's true that I need to compile it for android. But somebody recommend that compile the node-sqlite3 into Node.js as a core module.
Hi @wtchaos ,
Native modules need to be cross compiled for Android. This is something the nodejs-mobile-cordova
and nodejs-mobile-react-native
plugins do. There's a sample for each plugin that runs the sqlite3
module sample code:
https://github.com/janeasystems/nodejs-mobile-samples/tree/1eb9c4c0f1e02b009ca55bc610cc9e8cda403afa/cordova/UseNativeModules
and
https://github.com/janeasystems/nodejs-mobile-samples/tree/1eb9c4c0f1e02b009ca55bc610cc9e8cda403afa/react-native/UseNativeModules
I Embed the nodejs in my android native project,and deploy the nodejs project on android system, but
I don‘t know how to install the node modules(run command in terminal?),how can I solve it, thanks.