Build ReactNative source code for Android on developer machine

I want to know the way to build reactnative on my personal machine, and i tried to follow circleci steps but
got the following error

  1. I had tried to use crosstool-ng for cross compile and failed
  2. I tried to change NDK version from 20.1.5948944 to 21.4.7075529 and failed
  3. I have created the same env as docker-android still failed

Env

  System:
    OS: Linux 5.14 Manjaro Linux
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 4.67 GB / 15.41 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
    Yarn: 1.22.11 - /usr/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.17.5/bin/npm
    Watchman: 4.9.0 - /usr/bin/watchman
  Managers:
    pip3: 20.3.4 - /usr/bin/pip3
    RubyGems: 3.2.21 - /usr/bin/gem
  Utilities:
    Bazel: 4.2.0 - /usr/bin/bazel
    Make: 4.3 - /usr/bin/make
    GCC: 11.1.0 - /usr/bin/gcc
    Git: 2.33.0 - /usr/bin/git
    Clang: 12.0.1 - /usr/bin/clang
    FFmpeg: 4.4 - /usr/bin/ffmpeg
  Servers:
    Apache: 2.4.48 - /usr/bin/apachectl
  SDKs:
    Android SDK:
      API Levels: 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 31.0.0
      System Images: android-30 | Google APIs Intel x86 Atom
      Android NDK: 20.1.5948944
  IDEs:
    Android Studio: AI-203.7717.56.2031.7621141
    Nano: 5.8 - /usr/bin/nano
    VSCode: 1.60.0 - /usr/bin/code
    Vim: 8.2 - /usr/bin/vim
  Languages:
    Bash: 5.1.8 - /usr/bin/bash
    Java: 1.8.0_292 - /usr/bin/javac
    Perl: 5.34.0 - /usr/bin/perl
    Protoc: 3.17.3 - /usr/bin/protoc
    Python: 3.9.6 - /usr/bin/python
    Python3: 3.9.6 - /usr/bin/python3
    Ruby: 3.0.2 - /usr/bin/ruby
  Databases:
    MySQL: undefined - /usr/bin/mysql
    SQLite: 3.36.0 - /usr/bin/sqlite3
  Browsers:
    Firefox: 91.0.2

Main Error

/home/maxcalibur/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: warning: skipping incompatible /usr/lib/libdl.so while searching for dl
/home/maxcalibur/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: treating warnings as errors
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/maxcalibur/Workspace/nawb/third_party/react-native/ReactAndroid/build/tmp/buildReactNdkLib/local/armeabi-v7a/libreact_debug.so] Error 1
make: *** Waiting for unfinished jobs....
[armeabi-v7a] SharedLibrary  : libreact_render_debug.so
make: Leaving directory `/home/maxcalibur/Workspace/nawb/third_party/react-native/ReactAndroid/src/main/jni/react/jni'

> Task :ReactAndroid:buildReactNdkLib FAILED
16 actionable tasks: 6 executed, 10 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ReactAndroid:buildReactNdkLib'.
> Process 'command '/home/maxcalibur/Android/Sdk/ndk/20.1.5948944/ndk-build'' finished with non-zero exit value 2

Steps

  1. Install Buck deps ./scripts/circleci/buck_fetch.sh
  2. Install Gradle deps ./scripts/circleci/gradle_download_deps.sh
  3. build release node ./scripts/publish-npm.js --nightly

Source: Windows Questions C++

LEAVE A COMMENT