nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.21k stars 2.31k forks source link

Failed nx run mobile:build-android Command #27367

Closed hosseint79 closed 2 weeks ago

hosseint79 commented 1 month ago

Current Behavior

when I try to run this command npx nx run mobile:build-android I get error

Expected Behavior

Successfully APK file created

GitHub Repo

No response

Steps to Reproduce

  1. create new app
  2. add "build-android": { "executor": "@nx/react-native:build-android", "outputs": [ "{projectRoot}/build/outputs/bundle", "{projectRoot}/build/outputs/apk" ], "options": { "mode": "release" } }
  3. npx nx run mobile:build-android,

Nx Report

NX   Report complete - copy this into the issue template

Node   : 22.5.1
OS     : darwin-arm64
npm    : 10.8.2

nx                 : 19.4.1
@nx/js             : 19.4.1
@nx/jest           : 19.4.1
@nx/linter         : 19.4.1
@nx/eslint         : 19.4.1
@nx/workspace      : 19.4.1
@nx/devkit         : 19.4.1
@nx/eslint-plugin  : 19.4.1
@nx/next           : 19.4.1
@nx/playwright     : 19.4.1
@nx/react          : 19.4.1
@nx/react-native   : 19.4.1
@nrwl/tao          : 19.4.1
@nx/web            : 19.4.1
@nx/webpack        : 19.4.1
typescript         : 5.0.4
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin
@nx/react-native/plugin
@nx/webpack/plugin
@nx/playwright/plugin

Failure Logs

> Task :app:createBundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:createBundleReleaseJsAndAssets'.
> Couldn't determine Hermesc location. Please set `react.hermesCommand` to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc

Package Manager Version

No response

Operating System

Additional Information

No response

alexmyshchyshyn commented 4 weeks ago

@hosseint79 How did you solve it? Could you please help me with that?

hosseint79 commented 4 weeks ago

@alexmyshchyshyn Certainly! I’d be happy to help

1: My app was located at: /apps/mobile

2: I opened the build.gradle file located at: /apps/mobile/android/app/build.gradle

3: I uncommented the hermesCommand line and replaced it with: hermesCommand = "../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"

If your app isn't in /apps, you might need to adjust the hermesCommand path

alexmyshchyshyn commented 4 weeks ago

Thanks a lot @hosseint79. Found it some time ago too 🥇

akshgods commented 2 weeks ago

getting this error:

error: unknown option '--signing-config'

xiongemi commented 2 weeks ago

to solve this issue, need to set hermesCommand in your file /android/app/build.gradle: change the line // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" to something like hermesCommand = "../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"

depends on your app's directory offset from root