3

I am working on react native. When i try to create a build of android using

gradlew assembleRelease

then getting an

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'npx.cmd'' finished with non-zero exit value 1

But when i create a build using below command build succesfully build

gradlew assembleRelease -x bundleReleaseJsAndAssets 

But build not run on mobile device as i am opening my app after install it just crashed.

Also when i try to create build on different System (8gm ram) with same code then it creates build with same command and the build will successfully created. Provide me a solution for this,

Rover
  • 661
  • 2
  • 18
  • 39

3 Answers3

6

use cd android

after that use this ./gradlew clean

and for apk ./gradlew assembleRelease -x bundleReleaseJsAndAssets

or use this for aab ./gradlew bundleRelease -x bundleReleaseJsAndAssets

Try these commands and please tell me if it works

Bhupesh Kumar
  • 240
  • 2
  • 14
4

For me, I had to run npm run android once and then ./gradlew assembleRelease worked

UPDATE: Run following command and see output log to find the bug

npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

Hamza Waleed
  • 1,334
  • 10
  • 12
1

Personally, I had to run the app form within Android Studio. That gave me a clearer error message which allowed me to fix the issue.

The error in my case had to do with entryFile: "index.android.js", inside app/build.gradle. I had to change it to index.js since that was the entry point in my RN project.