Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to build on Android and iOS #7

Open
blueye opened this issue Jun 11, 2020 · 7 comments
Open

how to build on Android and iOS #7

blueye opened this issue Jun 11, 2020 · 7 comments

Comments

@blueye
Copy link

blueye commented Jun 11, 2020

I'm trying to build leveldown which can working with nodejs-mobile using nodejs-mobile-gyp.
I'm very confused with how to build on Android and iOS. There is no docs about it.
I have run following commands on ubuntu. As a result, it still built x86 arch which runs on linux.
Could you help me with how should I use the nodejs-mobile-gyp?

nodjs-mobile-gyp configure --dest-os=android --dest-cpu=arm
nodjs-mobile-gyp build --dest-os=android --dest-cpu=arm

and

nodjs-mobile-gyp configure --arch=arm
nodjs-mobile-gyp build --arch=arm
@jaimecbernardo
Copy link
Member

Hi @blueye ,
The way we are using nodejs-mobile-gyp is through the react-native and cordova plugins, which have to set environment variables when using npm rebuild --build-from-source to set the current node_gyp and node_headers, among other things.

Here's an example of how it's done by nodejs-mobile-react-native for ios: https://github.com/JaneaSystems/nodejs-mobile-react-native/blob/651425964f77a0520ba7c34c7cd6783b0ac1b6cf/scripts/ios-build-native-modules.sh#L50

Here's an example of how it's done by nodejs-mobile-react-native for android: https://github.com/JaneaSystems/nodejs-mobile-react-native/blob/651425964f77a0520ba7c34c7cd6783b0ac1b6cf/android/build.gradle#L368-L407

@Linoy339
Copy link

Linoy339 commented Aug 3, 2020

HI all,

Do we have any solution for this?

I am trying to establish offline db using pouch db in mobile.
I have an application which uses node express and pouch db. Its running well in my pc. I was able to take a build using webpack and tried in android/ios, which is not working.
IOS Error:
Error: No native build was found for platform=ios arch=arm64 runtime=node abi=57 uv=1 armv=8 libc=glibc at load.path (/private/var/mobile/Containers/Data/Application/74907299-A8BC-40E0-98CC-A5D65DDA491C/Documents/nodejs-project/api/node_modules/node-gyp-build/index.js:56:3)

Android Error:
Error: dlopen failed: cannot locate symbol "napi_get_global" referenced by "/data/data/digital.lamp.mindlamp/files/lampBuild/api/node_modules/leveldown/prebuilds/android-arm64/node.napi.armv8.node"...

Any help would be appreciated

@jaimecbernardo
Copy link
Member

You need to build leveldown against nodejs-mobile. Did you try the information from the previous comment?

@Linoy339
Copy link

@jaimecbernardo
I have tried. But mine is a native app which uses kotlene/swift. Native module compiling of leveldown seems complicated in this.
I tried with the commands above. But not worked

@jaimecbernardo
Copy link
Member

Hi @Linoy339 , In this comment , it links to parts of the way the plugins compile native modules, by setting environment variables that are picked up by npm to call the right gyp, use the nodejs-mobile headers, set the right architectures... Here are those links again:
https://github.com/JaneaSystems/nodejs-mobile-react-native/blob/651425964f77a0520ba7c34c7cd6783b0ac1b6cf/scripts/ios-build-native-modules.sh#L50
https://github.com/JaneaSystems/nodejs-mobile-react-native/blob/651425964f77a0520ba7c34c7cd6783b0ac1b6cf/android/build.gradle#L368-L407

@buu700
Copy link

buu700 commented Aug 30, 2021

@jaimecbernardo Is the behavior you referenced from nodejs-mobile-react-native also present in nodejs-mobile-cordova?

I'm also having issues with leveldown in nodejs-mobile-cordova, as well as with rocksdb and the leveldown-nodejs-mobile fork: staltz/leveldown-nodejs-mobile#1 (comment)

Error: dlopen failed: "/data/data/com.cyph.test/files/www/nodejs-project/node_modules/leveldown-nodejs-mobile/build/Release/leveldown.node" has bad ELF magic: cffaedfe

@fastalks
Copy link

fastalks commented May 5, 2023

Hi @blueye , The way we are using nodejs-mobile-gyp is through the react-native and cordova plugins, which have to set environment variables when using npm rebuild --build-from-source to set the current node_gyp and node_headers, among other things.

Here's an example of how it's done by nodejs-mobile-react-native for ios: https://github.com/JaneaSystems/nodejs-mobile-react-native/blob/651425964f77a0520ba7c34c7cd6783b0ac1b6cf/scripts/ios-build-native-modules.sh#L50

Here's an example of how it's done by nodejs-mobile-react-native for android: https://github.com/JaneaSystems/nodejs-mobile-react-native/blob/651425964f77a0520ba7c34c7cd6783b0ac1b6cf/android/build.gradle#L368-L407

hi @jaimecbernardo

I use nodejs-mobile-react-native for my android project ,and ../nodejs-assets/BUILD_NATIVE_MODULES.txt has been set 1 ,but I still got this error!

W/Thread-10: type=1400 audit(0.0:38498): avc: granted { execute } for path="/data/data/com.awesomeproject/files/nodejs-project/node_modules/classic-level/build/Release/node.napi.armv8.node" dev="sdd74" ino=188861 scontext=u:r:untrusted_app:s0:c212,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c212,c257,c512,c768 tclass=file app=com.awesomeproject E/nodejs: node:internal/modules/cjs/loader:1210 E/nodejs: return process.dlopen(module, path.toNamespacedPath(filename)); E/nodejs: ^ E/nodejs: E/nodejs: Error: dlopen failed: cannot locate symbol "napi_add_env_cleanup_hook" referenced by "/data/data/com.awesomeproject/files/nodejs-project/node_modules/classic-level/build/Release/node.napi.armv8.node"... E/nodejs: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18) E/nodejs: at Module.load (node:internal/modules/cjs/loader:1004:32) E/nodejs: at Function.Module._load (node:internal/modules/cjs/loader:839:12) E/nodejs: at Module.require (node:internal/modules/cjs/loader:1028:19) E/nodejs: at require (node:internal/modules/cjs/helpers:102:18) E/nodejs: at load (/data/data/com.awesomeproject/files/nodejs-project/node_modules/node-gyp-build/node-gyp-build.js:22:10) E/nodejs: at Object.<anonymous> (/data/data/com.awesomeproject/files/nodejs-project/node_modules/classic-level/binding.js:1:43) E/nodejs: at Module._compile (node:internal/modules/cjs/loader:1126:14) E/nodejs: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) E/nodejs: at Module.load (node:internal/modules/cjs/loader:1004:32) { E/nodejs: code: 'ERR_DLOPEN_FAILED' E/nodejs: } I/BpBinder: onLastStrongRef automatically unlinking death recipients: <uncached descriptor> E/NODEJS-MOBILE: exiting due to SIG_DFL handler for signal 11 A/libc: exiting due to SIG_DFL handler for signal 11 A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 17548 (FlipperEventBas), pid 17458 (.awesomeproject)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants