react-native: Task :app:bundleReleaseJsAndAssets FAILED

I’m following this to get my signed APK

Description

Executing ./gradlew bundleRelease or ./gradlew assembleRelease however gives an error. > Task :app:bundleReleaseJsAndAssets warning: the transform cache was reset. Loading dependency graph, done. info Writing bundle output to:, A:\Documents\React info Writing sourcemap output to:, A:\Documents\React info Done writing bundle output info Done writing sourcemap output info Copying 33 asset files error EEXIST: file already exists, mkdir 'A:\Documents\React'. Run CLI with --verbose flag for more details. Error: EEXIST: file already exists, mkdir 'A:\Documents\React'

> Task :app:bundleReleaseJsAndAssets FAILED FAILURE: Build failed with an exception. Execution failed for task ':app:bundleReleaseJsAndAssets'

React Native version:

Binaries: Node: 13.10.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD SDKs: Android SDK: API Levels: 23, 25, 28, 29 Build Tools: 25.0.2, 28.0.3, 29.0.2, 29.0.3, 30.0.0 System Images: android-18 | Google APIs ARM EABI v7a, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom IDEs: Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6241897 npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5

Expected Results

Getting a signed apk file. ./gradlew assembleDebug works with no issues

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (1 by maintainers)

Most upvoted comments

I fixed it using these steps;

  1. 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
  2. cd android
  3. gradlew clean
  4. gradlew assembleRelease -x bundleReleaseJsAndAssets

Source: Stackoverflow

by using this, apk was created but crashed when open

I fixed it using these steps;

  1. 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

  2. cd android

  3. gradlew clean

  4. gradlew assembleRelease -x bundleReleaseJsAndAssets

Source: Stackoverflow

Just open the project in cmd (administrator mode) in android folder run $ gradlew clean $ gradlew assembleRelease

Following the official react native publishing tutorial to the point where you have to gradlew bundleRelease (your app has to be signed)

If that command fails, then: -Go to android/app/src/main/res -Delete the drawable(s) folder(s) and raws folder -gradlew clean then gradlew --stop just to be safe -Run gradlew bundleRelease The build should succeed with your app.aad build file saved under android/app/build/outputs/bundle/release/app.aab

Edit 0: The files being deleted are leftovers that interfere with Task :app:bundleReleaseJsAndAssets, looking a bit further into the logs shows errors about duplicate assets. Edit 1: Unless you need an apk for a very specific reason, using aab is always a better practice (for a lower app size mainly)

I’m having this issue too. When I try to run a release with ./gradlew bundleRelease or react-native run-android --variant=release.

Try setting bundleInRelease to false, it worked for me

project.ext.react = [
  enableHermes: true,
  bundleInRelease: false // Add this line
]

Try setting bundleInRelease to false, it worked for me

project.ext.react = [
  enableHermes: true,
  bundleInRelease: false // Add this line
]

what will this line do?

I faced this same issue on Mac OS, was related to metro-bundler not having access to the folder in which my project was kept. I restarted my system and re-run the command. The bundler asked for permission to access the folder and after that I was able to generate the build.

Hope it helps. Thanks

I had the exact error and all I did was

./gradlew clean

and it build successfully

I was facing the same issue and tried the solutions mentioned above, but nothing helps. Then, I rename my folder, removing the space between the words (eg: “React Native” -> “React-Native”) and my problem was solved.

I fixed it using these steps;

  1. 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
  2. cd android
  3. gradlew clean
  4. gradlew assembleRelease -x bundleReleaseJsAndAssets

Source: Stackoverflow

Thanks.

My problem was that I ran gradlew assembleRelease from Git Bash on Windows.

I switched from Git Bash to cmd with Administrator rights and entered yarn react-native bundle instead of react-native bundle on first step, and it worked.

I fixed it using these steps;

  1. 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
  2. cd android
  3. gradlew clean
  4. gradlew assembleRelease -x bundleReleaseJsAndAssets

Source: Stackoverflow

by using this, apk was created but crashed when open

Had this exact same issue happen to me. I have created the keystore, updated the values in gradle.properties and app/build.gradle file.

Also, it happens when you change index.js to index.tsx. Go back to .js.

I found this works for me, tell me if it works for you too:

-    "@babel/core": "^7.13.14",   // & 7.13.13  Android App build failed.
+    "@babel/core": "^7.13.10",   // Android App build works fine.

Try to downgrade @babel/core to v7.13.10, if you are using a newer version