Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task :app:bundleReleaseJsAndAssets FAILED #28510

Closed
usersina opened this issue Apr 3, 2020 · 31 comments
Closed

Task :app:bundleReleaseJsAndAssets FAILED #28510

usersina opened this issue Apr 3, 2020 · 31 comments
Labels
Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.

Comments

@usersina
Copy link

usersina commented Apr 3, 2020

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

@andrewdazs
Copy link

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

@react-native-bot react-native-bot added the Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used. label Apr 10, 2020
@chrisglein chrisglein added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Apr 15, 2020
@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

@usersina
Copy link
Author

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

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Apr 16, 2020
@jitu94517
Copy link

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

@AnuragVadd
Copy link

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.

@liamkernighan
Copy link

liamkernighan commented Jun 25, 2020

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.

@atultiwari1996
Copy link

I faced this issue in window because window system need to install below package.
https://www.microsoft.com/en-us/download/details.aspx?id=48145
Install above package and clean project after that run ./gradlew assembleRelase command.

ipmsgclip_s_1593606923_0

@PriyashanJayasankha
Copy link

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 have the same issue , any solution ?

@usersina
Copy link
Author

usersina commented Jul 21, 2020

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)

@chrisglein
Copy link

There's some solutions suggested above. Running git bash admin, installing that package. With those is anyone still blocked here?

@chrisglein chrisglein added Needs: Author Feedback and removed Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 labels Aug 19, 2020
@KarineValenca
Copy link

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.

@stale
Copy link

stale bot commented Dec 25, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 25, 2020
@hustcer
Copy link

hustcer commented Apr 9, 2021

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

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 9, 2021
@hustcer
Copy link

hustcer commented Apr 9, 2021

@babel/core 7.13.13, 7.13.14, 7.13.15 all doesn't work for me, and v7.13.10 works!

@Enesklmc
Copy link

Enesklmc commented Jun 4, 2021

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

@qasimgit
Copy link

qasimgit commented Jul 9, 2021

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

@Kirsten1996
Copy link

@usersina's answer has helped me past this issue

Following the [official react native publishing tutorial](https://reactnative.dev/docs/signed-apk-android) 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
cd back into the android 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 not sure if this issue is

@Orlayhemmy
Copy link

I had the exact error and all I did was

./gradlew clean

and it build successfully

@Dev-Siri
Copy link

Dev-Siri commented Oct 15, 2022

Try setting bundleInRelease to false, it worked for me

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

@Rasantis
Copy link

any new solution ??

@Hassaan0
Copy link

Try setting bundleInRelease to false, it worked for me

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

what will this line do?

@rodrigodiasf1984
Copy link

rodrigodiasf1984 commented Jan 18, 2023

cd android/
./gradlew clean
./gradlew bundleRelease

React-native 0.68.2,
"react": "17.0.2",
node v18.13.0

This works to me!

@cortinico
Copy link
Contributor

I'm closing this issue as this is from 2020.
If you're experiencing the same issue on React Native 0.71, please open a new issue and we'll look into it.

@98rahul
Copy link

98rahul commented Feb 2, 2023

getting same error in order to get rid of this error

as i am following this article and triggering bunch of errors
using this command
./gradlew clean build --refresh-dependencies --no-build-cache

New Version

0.71.1

Old Version

0.63.4

@ManalLiaquat
Copy link

ManalLiaquat commented Feb 14, 2023

The solution is so simple,

your project ancestors folder names should not contain spaces, like in your error: A:\Documents\React [some ancestor folder with space name]

@ChawkiOS
Copy link

Try setting bundleInRelease to false, it worked for me

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

Magic ! thanks.

@AbhinavGupta2008
Copy link

Try setting bundleInRelease to false, it worked for me

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

Magic ! thanks.

Where do we have to add this line??

@tnson1307
Copy link

Try setting bundleInRelease to false, it worked for me

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

Magic ! thanks.

Where do we have to add this line??

you can see it in android/app/build.gradle

@arpansharma7474
Copy link

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

@Anand14001
Copy link

@arpansharma7474 @tnson1307 @hustcer @ChawkiOS @KarineValenca

why im getting this error i wan to fix it and generate apk

Task :app:createBundleReleaseJsAndAssets
Starting Metro Bundler
warning: Bundler cache is empty, rebuilding (this may take a minute)
Error: Unable to resolve module .\node_modules\expo\AppEntry.js from D:\New folder (16)\final login\login-app/.: .\node_modules\expo\AppEntry.js could n
ot be found within the project or in these directories:
node_modules
Error: Unable to resolve module .\node_modules\expo\AppEntry.js from D:\New folder (16)\final login\login-app/.: .\node_modules\expo\AppEntry.js could n
ot be found within the project or in these directories:
node_modules
at ModuleResolver.resolveDependency (D:\New folder (16)\final login\login-app\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:
138:15)
at DependencyGraph.resolveDependency (D:\New folder (16)\final login\login-app\node_modules\metro\src\node-haste\DependencyGraph.js:231:43)
at D:\New folder (16)\final login\login-app\node_modules\metro\src\lib\transformHelpers.js:156:21
at Server._resolveRelativePath (D:\New folder (16)\final login\login-app\node_modules\metro\src\Server.js:1023:12)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at MetroBundlerDevServer.resolveRelativePathAsync (D:\New folder (16)\final login\login-app\node_modules@expo\cli\src\start\server\metro\MetroBundl
erDevServer.ts:1204:12)
at MetroBundlerDevServer.metroLoadModuleContents (D:\New folder (16)\final login\login-app\node_modules@expo\cli\src\start\server\metro\MetroBundle
rDevServer.ts:429:35)
at MetroBundlerDevServer.legacySinglePageExportBundleAsync (D:\New folder (16)\final login\login-app\node_modules@expo\cli\src\start\server\metro\M
etroBundlerDevServer.ts:552:20)
at exportEmbedBundleAndAssetsAsync (D:\New folder (16)\final login\login-app\node_modules@expo\cli\src\export\embed\exportEmbedAsync.ts:116:21)
at exportEmbedAsync (D:\New folder (16)\final login\login-app\node_modules@expo\cli\src\export\embed\exportEmbedAsync.ts:68:30)

Task :app:createBundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:createBundleReleaseJsAndAssets'.

Process 'command 'cmd'' finished with non-zero exit value 1

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

npx react-native info :

System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Memory: 1.09 GB / 7.88 GB
Binaries:
Node:
version: 20.12.2
path: C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm:
version: 10.5.2
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "34"
Build Tools:
- 34.0.0
System Images:
- android-32 | Google Play Intel x86_64 Atom
Android NDK: Not Found
Windows SDK:
AllowAllTrustedApps: Disabled
Versions:
- 10.0.16299.0
IDEs:
Android Studio: AI-233.14808.21.2331.11709847
Visual Studio:
- 16.10.31424.327 (Visual Studio Community 2019)
Languages:
Java: 17.0.11
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.2
wanted: 0.74.2
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

package.json:
{
"name": "login-app",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@expo/metro-runtime": "~3.2.1",
"@fontsource/roboto": "^5.0.13",
"@mui/icons-material": "^5.15.19",
"@mui/material": "^5.15.19",
"@mui/styled-engine-sc": "^6.0.0-alpha.18",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-firebase/app": "^19.2.2",
"@react-native-firebase/auth": "^19.2.2",
"@react-native-masked-view/masked-view": "0.3.1",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"@react-navigation/stack": "^6.3.29",
"axios": "^1.7.2",
"expo": "~51.0.13",
"expo-image-picker": "~15.0.5",
"expo-local-authentication": "~14.0.1",
"expo-navigation-bar": "~3.0.6",
"expo-status-bar": "~1.12.1",
"firebase": "^10.11.0",
"lottie-react-native": "6.7.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.2",
"react-native-fieldset": "^1.0.3",
"react-native-gesture-handler": "~2.16.1",
"react-native-navigation": "^7.40.0",
"react-native-navigation-bar-color": "^2.0.2",
"react-native-paper": "^5.12.3",
"react-native-swiper": "^1.6.0",
"react-native-vector-icons": "^10.0.3",
"react-native-web": "~0.19.10",
"styled-components": "^6.1.11"
},
"devDependencies": {
"@babel/core": "^7.24.0",
"react-bootstrap": "^2.10.2"
},
"private": true
}

@SubhamShaww
Copy link

In my case downgrading the node version from 20 to 16lts worked. it worked for both old builds supporting api level 31 and api level 33 as well.

in my case, all the node modules were not of latest version in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.
Projects
None yet
Development

No branches or pull requests