Open Linoy339 opened 4 years ago
HI, Do I need to tweak anything in my binary or library to get it work?
Can we use in native mobile app?
@staltz I'm seeing the same run-time error when I require this module: 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
This is reproducible whether I build the APK from macOS on x86 or macOS on ARM, and whether I run it from a physical device (Pixel 5) or an emulated device. I'm running node@16.8.0, cordova@10.0.0, and cordova-android@10.0.1.
Edit: Also reproduced with node@14.17.5.
@buu700 I'm having this issue as well. Did you find a solution for Android?
Unfortunately not, we're just sticking with IndexedDB/Dexie in our mobile apps instead for now.
Sorry I couldn't respond to this issue, I don't have the time for all my open source libraries. The best I can advise you right now is to take a look at the Manyverse codebase and see if you can learn something from there, e.g.
I'm aware that with Cordova the build setup is significantly different. Manyverse is using React Native.
For Cordova I also worked on another project, Ahau, that used nodejs-mobile and leveldown, perhaps their build scripts can give you some insight:
Appreciate you leaving these detailed comments and examples! We will explore Manyverse to try to get our Android build working. When we figure it out, I hope to leave notes to help future devs who use this repo. (Side note – We're using React Native.)
I included a few of the build scripts, notably build-native-modules.sh and move-shared-libs-android.sh, and got it working on device! Still not working on emulator, but that's ok for our purposes. Thanks again @staltz !
Note that I also needed to modify android/settings.gradle
and android/app/build.gradle
to get it working, and set NODEJS_MOBILE_BUILD_NATIVE_MODULES=1
in android/gradle.properties
.
Great to hear! Just as a data point, I also have never gotten it working on emulators (which run in x86 architecture).
I have used leveldown-nodejs-mobile, as it was supposed to work. but couldn't work.
In Android, it says : Error: dlopen failed: "/data/data/digital.lamp.mindlamp/files/lampBuild/api/node_modules/leveldown/build/Release/leveldown.node" has bad ELF magic: cffaedfe at Object.Module._extensions..node (module.js:653:18)
In IOS, it says: dlopen(/private/var/mobile/Containers/Data/Application/D1BA5C5F-4140-4E74-86E9-DA126EA579D2/Documents/nodejs-project/api/node_modules/leveldown/build/Release/leveldown.node, 1): no suitable image found. Did find: /private/var/mobile/Containers/Data/Application/D1BA5C5F-4140-4E74-86E9-DA126EA579D2/Documents/nodejs-project/api/node_modules/leveldown/build/Release/leveldown.node: mach-o, but wrong architecture /private/var/mobile/Containers/Data/Application/D1BA5C5F-4140-4E74-86E9-DA126EA579D2/Documents/nodejs-project/api/node_modules/leveldown/build/Release/leveldown.node: mach-o, but wrong architecture
Could you help?