staltz / leveldown-nodejs-mobile

Pure C++ Node.js LevelDB binding serving as the back-end to LevelUP — Specific to Node.js for Mobile
MIT License
3 stars 4 forks source link

Android NDK 23 compilation problem #4

Closed viniciuscb closed 1 year ago

viniciuscb commented 1 year ago

The newer version of react native uses NDK 23.1.7779620

In this NDK version the module leveldown-nodejs-mobile stopped to compile.

Apparently this is the cause.

When compiling, the compiler tried to find the files ~/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/{aarch64-linux-android-ar,arm-linux-androideabi-ar,x86_64-linux-android-ar}. These are not available anymore since NDK 23.

Compile output:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
npm verb cli /home/dev/.nvm/versions/node/v16.19.1/bin/node /home/dev/.nvm/versions/node/v16.19.1/bin/npm
npm info using npm@8.19.3
npm info using node@v16.19.1
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/home/dev/.nvm/versions/node/v16.19.1/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 4ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:/home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/.npmrc Completed in 1ms
npm timing config:load:project Completed in 7ms
npm timing config:load:file:/home/dev/.npmrc Completed in 1ms
npm timing config:load:user Completed in 2ms
npm timing config:load:file:/home/dev/.nvm/versions/node/v16.19.1/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 2ms
npm timing config:load:setEnvs Completed in 0ms
npm timing config:load Completed in 18ms
npm timing npm:load:configload Completed in 20ms
npm timing npm:load:mkdirpcache Completed in 0ms
npm timing npm:load:mkdirplogs Completed in 0ms
npm verb title npm rebuild
npm verb argv "--loglevel" "verbose" "--foreground-scripts" "rebuild" "--build-from-source"
npm timing npm:load:setTitle Completed in 1ms
npm timing config:load:flatten Completed in 3ms
npm timing npm:load:display Completed in 6ms
npm verb logfile logs-max:10 dir:/home/dev/.npm/_logs
npm verb logfile /home/dev/.npm/_logs/2023-03-06T03_11_29_553Z-debug-0.log
npm timing npm:load:logFile Completed in 5ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 34ms
npm timing arborist:ctor Completed in 0ms
npm verb shrinkwrap failed to load node_modules/.package-lock.json out of date, updated: node_modules
npm timing build:queue Completed in 8ms
npm timing build:link:node_modules/esprima-fb Completed in 7ms
npm timing build:link:node_modules/commoner Completed in 10ms
npm timing build:link:node_modules/pouchdb-core/node_modules/uuid Completed in 9ms
npm timing build:link:node_modules/pouchdb-mapreduce-utils/node_modules/uuid Completed in 9ms
npm timing build:link:node_modules/pouchdb-utils/node_modules/uuid Completed in 8ms
npm timing build:link:node_modules/pouchdb-abstract-mapreduce/node_modules/uuid Completed in 9ms
npm timing build:link:node_modules/pouchdb-find/node_modules/uuid Completed in 9ms
npm timing build:link:node_modules/acorn Completed in 11ms
npm timing build:link:node_modules/errno Completed in 10ms
npm timing build:link:node_modules/esprima Completed in 10ms
npm timing build:link:node_modules/get-folder-size Completed in 10ms
npm timing build:link:node_modules/jstransform Completed in 11ms
npm timing build:link:node_modules/mime Completed in 11ms
npm timing build:link:node_modules/mkdirp Completed in 11ms
npm timing build:link:node_modules/node-gyp-build Completed in 11ms
npm timing build:link:node_modules/uuid Completed in 10ms
npm timing build:link:node_modules/recast/node_modules/esprima Completed in 9ms
npm timing build:link Completed in 13ms
npm info run leveldown-nodejs-mobile@5.4.1-3 install node_modules/leveldown-nodejs-mobile $PROJECT_DIR/../node_modules/.bin/node-gyp-build-mobile
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/home/dev/.nvm/versions/node/v16.19.1/bin/node',
gyp verb cli   '/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild'
gyp verb cli ]
gyp info using node-gyp@0.3.1
gyp info using node@16.19.1 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /home/dev/.pyenv/shims/python2
gyp verb check python version `/home/dev/.pyenv/shims/python2 -c "import sys; print "2.7.18
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir compiling against specified --nodedir dev files: /home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-react-native/android/libnode/
gyp verb build dir attempting to create "build" dir: /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile/build
gyp verb build dir "build" dir needed to be created? /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile/build/config.gypi
(node:519192) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
(Use `node --trace-deprecation ...` to show where the warning was created)
gyp verb config.gypi checking for gypi file: /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile/config.gypi
gyp verb common.gypi checking for gypi file: /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /home/dev/.pyenv/shims/python2
gyp info spawn args [
gyp info spawn args   '/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make-android',
gyp info spawn args   '-I',
gyp info spawn args   '/home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-react-native/android/libnode/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-react-native/android/libnode/',
gyp info spawn args   '-Dnode_gyp_dir=/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-react-native/android/libnode/$(Configuration)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture arm64
gyp verb node dev dir /home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-react-native/android/libnode/
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
/bin/sh: 1: /home/dev/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar: not found
make: *** [deps/leveldb/leveldb.target.mk:194: Release/obj.target/deps/leveldb/leveldb.a] Erro 127
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-gyp/lib/build.js:248:23)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Linux 5.10.0-18-amd64
gyp ERR! command "/home/dev/.nvm/versions/node/v16.19.1/bin/node" "/home/dev/Workspace/pegadas-app/node_modules/nodejs-mobile-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile
gyp ERR! node -v v16.19.1
gyp ERR! node-gyp -v v0.3.1
gyp ERR! not ok 
npm info run leveldown-nodejs-mobile@5.4.1-3 install { code: 1, signal: null }
npm timing command:rebuild Completed in 21270ms
npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (/home/dev/.nvm/versions/node/v16.19.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
npm verb stack     at ChildProcess.emit (node:events:513:28)
npm verb stack     at maybeClose (node:internal/child_process:1100:16)
npm verb stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm verb pkgid leveldown-nodejs-mobile@5.4.1-3
npm verb cwd /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project
npm verb Linux 5.10.0-18-amd64
npm verb node v16.19.1
npm verb npm  v8.19.3
npm ERR! code 1
npm ERR! path /home/dev/Workspace/pegadas-app/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project/node_modules/leveldown-nodejs-mobile
npm ERR! command failed
npm ERR! command sh -c -- $PROJECT_DIR/../node_modules/.bin/node-gyp-build-mobile
npm verb exit 1
npm timing npm Completed in 21458ms
npm verb unfinished npm timer build 1678072290009
npm verb unfinished npm timer build:deps 1678072290009
npm verb unfinished npm timer build:run:install 1678072290031
npm verb unfinished npm timer build:run:install:node_modules/leveldown-nodejs-mobile 1678072290032
npm verb code 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dev/.npm/_logs/2023-03-06T03_11_29_553Z-debug-0.log

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nodejs-mobile-react-native:BuildNpmModulesarm64-v8a'.
> 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.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 37s

    at makeError (/home/dev/Workspace/pegadas-app/node_modules/execa/index.js:174:9)
    at /home/dev/Workspace/pegadas-app/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/home/dev/Workspace/pegadas-app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:82:7)
    at async Command.handleAction (/home/dev/Workspace/pegadas-app/node_modules/@react-native-community/cli/build/index.js:108:9)
info Run CLI with --verbose flag for more details.
staltz commented 1 year ago

Well spotted. Thanks. I just made a new version of nodejs-mobile-react-native that fixes this. No changes needed in leveldown-nodejs-mobile