facebook / react-native

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

Execution failed for task ':app:createBundleReleaseJsAndAssets' on Release build #35927

Closed douglasndm closed 1 year ago

douglasndm commented 1 year ago

Description

I'm trying to upgrade to RN 0.71.1 from 0.70.6 and I used to use "project.ext.react" to set the "hermesCommand" path. Like this

> project.ext.react = [
>   enableHermes: true,
>    cliPath: "../../../../node_modules/react-native/cli.js",
>   composeSourceMapsPath: "../../node_modules/react-native/scripts/compose-source-maps.js",
>    hermesCommand: '../../../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc',
]

but since I upgraded to RN 0.71.1 every time when I try to build a release build for Android I got this error

> Execution failed for task ':app:createBundleReleaseJsAndAssets'.
> A problem occurred starting process 'command '../../../../node_modules/react-native/sdks/hermesc/osx-bin/hermesc''

I'm using a monorepo so this is why my path to RN is different. 
I'm using the following new RN config way

react {
>    reactNativeDir = file("../../../../node modules/react-native")
>   codegenDir = file("../../../../node-modules/react-native-codegen")
>   cliFile = file("../../../../node_modules/react-native/cli.js")    
>    hermesCommand = '../../../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc'
}

package.json of root

"devDependencies": {
        "@babel/core": "^7.20.0",
        "@babel/preset-env": "^7.20.0",
        "@babel/preset-typescript": "^7.16.7",
        "@babel/runtime": "^7.20.0",
        "@react-native-community/eslint-config": "^3.0.0",
        "@tsconfig/react-native": "^2.0.2",
        "@types/jest": "^29.2.1",
        "@types/react": "^18.0.24",
        "@types/react-test-renderer": "^18.0.0",
        "@typescript-eslint/eslint-plugin": "^5.46.1",
        "@typescript-eslint/parser": "^5.46.1",
        "babel-jest": "^29.2.1",
        "eslint": "^8.19.0",
        "eslint-config-airbnb": "^19.0.4",
        "eslint-config-prettier": "^6.11.0",
        "eslint-import-resolver-typescript": "^2.2.1",
        "eslint-plugin-import": "^2.20.1",
        "eslint-plugin-jsx-a11y": "^6.2.3",
        "eslint-plugin-prettier": "^3.1.4",
        "eslint-plugin-react": "^7.19.0",
        "eslint-plugin-react-hooks": "^4.6.0",
        "jest": "^29.2.1",
        "prettier": "^2.4.1",
        "typescript": "4.8.4"
    }

And package.json of the app

  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.17.11",
    "@react-native-community/blur": "^4.2.0",
    "@react-native-community/push-notification-ios": "^1.10.1",
    "@react-native-community/slider": "^3.0.3",
    "@react-native-firebase/analytics": "^14.8.0",
    "@react-native-firebase/app": "^14.8.0",
    "@react-native-firebase/messaging": "^14.8.0",
    "@react-native-firebase/remote-config": "^14.8.0",
    "@react-native-masked-view/masked-view": "^0.2.8",
    "@react-native-picker/picker": "^2.4.8",
    "@react-navigation/drawer": "^6.5.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/native-stack": "^6.9.1",
    "@react-navigation/stack": "^6.3.2",
    "@sentry/react-native": "^4.13.0",
    "axios": "^0.23.0",
    "crypto-js": "^3.3.0",
    "date-fns": "^2.29.2",
    "deprecated-react-native-prop-types": "^2.3.0",
    "lottie-react-native": "^5.1.4",
    "polished": "^4.1.1",
    "react": "18.2.0",
    "react-native": "0.71.1",
    "react-native-background-fetch": "^4.1.3",
    "react-native-camera": "^4.2.1",
    "react-native-code-push": "^7.0.5",
    "react-native-config": "^1.4.12",
    "react-native-currency-input": "^1.0.1",
    "react-native-date-picker": "^4.1.1",
    "react-native-device-info": "^10.0.2",
    "react-native-dialog": "^9.3.0",
    "react-native-document-picker": "^8.1.1",
    "react-native-fast-image": "^8.5.11",
    "react-native-flash-message": "^0.3.1",
    "react-native-format-currency": "^0.0.3",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "^2.8.0",
    "react-native-google-mobile-ads": "^5.0.0",
    "react-native-image-picker": "^4.7.3",
    "react-native-in-app-review": "^3.2.2",
    "react-native-iphone-x-helper": "^1.3.1",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-localization": "^2.1.7",
    "react-native-localize": "^2.1.1",
    "react-native-paper": "^4.9.2",
    "react-native-permissions": "^3.0.5",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-picker-select": "^8.0.4",
    "react-native-purchases": "^5.2.2",
    "react-native-push-notification": "^8.1.0",
    "react-native-qrcode-scanner": "^1.5.5",
    "react-native-reanimated": "^2.14.1",
    "react-native-safe-area-context": "^4.4.1",
    "react-native-screens": "^3.18.2",
    "react-native-share": "^7.2.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-uuid-generator": "^6.1.1",
    "react-native-vector-icons": "^9.1.0",
    "react-native-zip-archive": "^6.0.3",
    "react-number-format": "^4.4.1",
    "realm": "^11.3.2",
    "shared": "^1.0.0",
    "styled-components": "^5.3.6",
    "xlsx": "^0.17.0",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@rnx-kit/align-deps": "^2.0.3",
    "@types/crypto-js": "^3.1.47",
    "@types/react-native-push-notification": "^5.0.5",
    "@types/react-native-share": "^3.3.0",
    "@types/react-native-uuid-generator": "^4.0.0",
    "@types/react-native-vector-icons": "^6.4.5",
    "@types/react-test-renderer": "^17.0.1",
    "@types/styled-components-react-native": "^5.1.3",
    "babel-plugin-module-resolver": "^4.1.0",
    "jetifier": "^1.6.6",
    "metro-react-native-babel-preset": "^0.73.7",
    "patch-package": "^6.2.2",
    "react-native-typescript-transformer": "^1.2.13",
    "react-test-renderer": "18.2.0",
    "ts-jest": "^27.1.4",
    "typescript": "*"
  },

Version

0.71.1

Output of npx react-native info

System: OS: macOS 13.0 CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz Memory: 111.01 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.0/bin/yarn npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm Watchman: 2022.10.17.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Init a monorepo repository with this structure root (package.json) RN is Here -> packages -> app (package.json)

Correct the path in react config inside app/build.gradle

react {
>    reactNativeDir = file("../../../../node modules/react-native")
>   codegenDir = file("../../../../node-modules/react-native-codegen")
>   cliFile = file("../../../../node_modules/react-native/cli.js")    
>    hermesCommand = '../../../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc'
}

Try to build a release build with

./gradlew bundleRelease

Snack, code example, screenshot, or link to a repository

Screenshot 2023-01-21 at 17 39 33

cortinico commented 1 year ago

hermesCommand = '../../../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc'

I think your path is not correct. The hermesCommand path is relative from your app folder. What happens if you:

cd app && ../../../../node_modules/react-native/sdks/hermesc/osx-bin/hermesc 

You should see something like:

Please choose output, e.g. -emit-binary. hermesc does not support -exec.
Example: hermesc -emit-binary -out myfile.hbc myfile.js
douglasndm commented 1 year ago

hermesCommand = '../../../../node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc'

I think your path is not correct. The hermesCommand path is relative from your app folder. What happens if you:

cd app && ../../../../node_modules/react-native/sdks/hermesc/osx-bin/hermesc 

You should see something like:

Please choose output, e.g. -emit-binary. hermesc does not support -exec.
Example: hermesc -emit-binary -out myfile.hbc myfile.js

Thanks a lot, that solve my problem.

From my app folder, I needed to go back only two folders and it fixed it.

kkmate commented 1 year ago

Thanks guys! I think it is important to note here that app folder here means where your root of your react native project lies (where your package.json is) and not the android/app/ folder where the build.gradle is which you are editing. It was confusing to me. (The rest of the config is relative to android/app)

MechLocator commented 1 year ago

Was this issue closed??