facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.38k stars 24.36k forks source link

Not able to build on aarch64 machine #47533

Open jabedzaman opened 1 week ago

jabedzaman commented 1 week ago

Description

I am trying to assemble the apk but getting error.. I have used sdkmanager to install the sdks and also i have node 20 along with open-jdk-17

Steps to reproduce

  1. use aarch64 based machine
  2. create a new react native app
  3. cd android
  4. ./gradlew assembleDebug || ./gradlew assembleRelease || ./gradlew bundleRelease

React Native Version

0.76.1

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
  CPU: (4) arm64 Neoverse-N1
  Memory: 20.38 GB / 23.42 GB
  Shell:
    version: "5.9"
    path: /usr/bin/zsh
Binaries:
  Node:
    version: 20.18.0
    path: /run/user/1001/fnm_multishells/226019_1731204517984/bin/node
  Yarn:
    version: 1.22.22
    path: /run/user/1001/fnm_multishells/226019_1731204517984/bin/yarn
  npm:
    version: 10.8.2
    path: /run/user/1001/fnm_multishells/226019_1731204517984/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-33 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

➜  android git:(main) ✗ ./gradlew bundleRelease

> Task :app:createBundleReleaseJsAndAssets
debug Using @react-naive-community/cli-tools' logger
debug Reading Metro config from /home/ubuntu/developer/grape/metro.config.js
 WARN  the transform cache was reset.
                Welcome to Metro v0.81.0
              Fast - Scalable - Integrated

info Writing bundle output to: /home/ubuntu/developer/grape/android/app/build/generated/assets/createBundleReleaseJsAndAssets/index.android.bundle
info Writing sourcemap output to: /home/ubuntu/developer/grape/android/app/build/intermediates/sourcemaps/react/release/index.android.bundle.packager.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 1 asset files
info Done copying assets

> Task :app:createBundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:createBundleReleaseJsAndAssets'.
> OS not recognized. Please set project.react.hermesCommand to the path of a working Hermes compiler.

* 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 18s
14 actionable tasks: 4 executed, 10 up-to-date

Reproducer

https://github.com/facebook/react-native

Screenshots and Videos

No response

react-native-bot commented 1 week ago

[!WARNING] Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

shubhamguptadream11 commented 1 week ago

@jabedzaman How did you created a new app? Are you using this command: npx @react-native-community/cli init <app_name>. Also provide a valid reproducer.

jabedzaman commented 1 week ago

@jabedzaman How did you created a new app? Are you using this command: npx @react-native-community/cli init <app_name>. Also provide a valid reproducer.

yesss!!! tried with init command only + not the older cli tool too!! And this error only comes on arm linux not on x86 ones.. the same code runs properly on apple arm and other x86 machines

oddlyspaced commented 1 week ago

@jabedzaman Have you tried compiling normal Android gradle projects? I tried setting up a Raspberry Pi to be used as a CI some time back, but realised that a lot of tools used in the build pipeline don't support ARM64. Maybe its a similar reason for you?

jabedzaman commented 1 week ago

@jabedzaman Have you tried compiling normal Android gradle projects? I tried setting up a Raspberry Pi to be used as a CI some time back, but realised that a lot of tools used in the build pipeline don't support ARM64. Maybe its a similar reason for you?

maybe yea i switched to x86 and everything is working fine again... but yea i do need a solution for builds on arm cause my main vps is using a arm cpu

oddlyspaced commented 1 week ago

as far as i know and based on my previous experimentation, the only real solution is to setup qemu and emulate x86 on arm64, however ymmv accordingly regarding performance.

jabedzaman commented 6 days ago

as far as i know and based on my previous experimentation, the only real solution is to setup qemu and emulate x86 on arm64, however ymmv accordingly regarding performance.

anything else??? i dont wanna go this setup qemu and emulate x86 this way beyond my understanding as of now..