react-native: bundleRelease Error: Execution failed for task ':app:bundleReleaseJsAndAssets'.
Description
React-Native-Build-Error
https://github.com/OmarThinks/ReactNativeBuildError
Acknowledgement:
Thank you so much React Native Team for your hard and consistent work.
Reporducability of issue:
Here the are 2 projects: https://github.com/OmarThinks/ReactNativeBuildError
I have created a Github repo to make it easy for you to spot the error.
JS and TS projects.
I have been stuck here for 3 consecutive days.
I tried everything I could find.
https://stackoverflow.com/questions/59695135/react-native-android-build-process-command-npx-cmd-finished-with-non-zero
https://github.com/facebook/react-native/issues/28510
None of these soltions worked.
I have also tried several React native versions, and tried changing Gradle versions, and JDK versions. None of these worked.
How I Generated these projects:
npx react-native init AwesomeProject
npx react-native init AwesomeTSProject --template react-native-template-typescript
I did not add any other code to the templates, just signning the keys.
Error:
$ ./gradlew bundleRelease
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 4s
8 actionable tasks: 3 executed, 5 up-to-date
Key:
Key is already generated on /android/app/my-upload-key.keystore
. But, if you want to regenerate a new key, you can follow the steps below:
keytool -genkey -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=abcdefghijklmnop
MYAPP_UPLOAD_KEY_PASSWORD=abcdefghijklmnop
Acknowledgement (Again):
Thank you so much React Native Team for your hard and consistent work.
You saved us from Java.
Version
0.70.6
Output of npx react-native info
$ npx react-native info info Fetching system and libraries information… System: OS: Windows 10 10.0.22621 CPU: (12) x64 Intel® Core™ i5-10400 CPU @ 2.90GHz Memory: 18.15 GB / 31.83 GB Binaries: Node: 18.12.1 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 30, 31, 32, 33 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0, 33.0.1 System Images: android-29 | Google Play Intel x86 Atom, android-31 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64 Android NDK: Not Found Windows SDK: AllowAllTrustedApps: Disabled Versions: 10.0.19041.0 IDEs: Android Studio: AI-213.7172.25.2113.9123335 Visual Studio: 17.2.32630.192 (Visual Studio Community 2022) Languages: Java: 11.0.17 - /c/Program Files/Eclipse Adoptium/jdk-11.0.17.8-hotspot/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
Reproduction:
1) GitHub Repo:
https://github.com/OmarThinks/ReactNativeBuildError
I have created this GitHub repo which contains all the code to help run the code easily.
2) Normal way of creating templates:
npx react-native init AwesomeProject
npx react-native init AwesomeTSProject --template react-native-template-typescript
Snack, code example, screenshot, or link to a repository
https://github.com/OmarThinks/ReactNativeBuildError
Thank you so much for your hard, patient, and persistent work!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 64 (13 by maintainers)
Hello! @therafibhuiyan
It must crash.
Because
.\gradlew app:assembleRelease -x bundleReleaseJsAndAssets
, that-x
I believe meanswithout
.So, there will be no bundling for Release of JS and Assists.
So, it must crash.
I will never ever use this
-x bundleReleaseJsAndAssets
again. 😃@OmarThinks The development of my application has been completed but I am unable to push it to the production build due to this issue.
RN official documentation According to the RN official documentation if we want to create an abb file then we have to use
./gradlew bundleRelease.
If this is a bad practice then why in the official documentation they mentioned this command to generate an abb file?@OmarThinks After doing some research, I was able to build a working APK. First I have to install React-Native globally by using
npm install -g react-native-cli
. I changed the ExecutionPolicy by runningSet-ExecutionPolicy Unrestricted
in PowerShell on administrator power, Then, I created a folder called assets inandroid/app/src/main/
this directory. Once that’s done, I runreact-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
from the root of the project and then run this./gradlew assembleRelease -x bundleReleaseJsAndAssets
from the android folder. Now I just have to create an abb file and let’s see what happens.Just a small heads up that I’ve tested this on 0.71 today and I can confirm that everything works as expected
Hello @OmarThinks , did you tried on Mac or Linux?
I have the same issue in both Windows 11 machines and i’m gonna try it on Mac from zero.
@therafibhuiyan
.\gradlew app:assembleRelease
.\gradlew bundleRelease
Are correct.
Or also you can use android studio to generate the APK or Bundle.
Top Bar => Build => Generate Signed Bundle / APK
All of these should work.
But, I meant that this
-x bundleReleaseJsAndAssets
is the one that I will never use again. 😃 😃Yeah. I agree with you! The React Native Team is doing Great work. I really can’t thank them enough.
They saved our souls from having to write Java.
I can’t acknowledge their hard work enough. But, I just would really appreciate resolving that tiny little bug. 😃 😃
My problem was the same as yours, but the command
.\gradlew app:assembleRelease -x bundleReleaseJsAndAssets
solved it for me now I am facing another issue, which is that when I run the commandnpx react-native run-android
everything is fine, but when I build an APK by using this command.\gradlew app:assembleRelease -x bundleReleaseJsAndAssets
it’s crashes.Hey @OmarThinks @cortinico ,
It actually worked on Mac with M1 chip. Just following the MacOS Android guides from React Native site.
My app is using react-native@0.71.1 compiled with Zulu11.
We also tried on Windows 11 and it failed. So it seems it’s a Windows issue.
Hope it helps 😃
In general, using any
./gradlew <command>
which are not described in the official documentation, is a bad practice, as you’re using flags that might impact your build.The
-x
flag will obviously make your app crash as you’re not bundling JS and images inside the final app.EDIT: Clarification
@7geekerLarr This is because you have a space in your path (
C:\PROYECTOS 2023\xaf
). A fix for this has been added - see this comment - and will be available in the next version or point release for RN71.@OmarThinks could you try again making sure there are no spaces in your path, as this could be a duplicate of https://github.com/facebook/react-native/issues/34878 ?
Thanks for the heads up. This seems to be a Windows specific issue. We’ll have to look into it next week.
Thanks for the update. That’s expected as we’re still in RC. You would need a beta of Android Studio to open it.
Does it work from the command line though?
@therafibhuiyan the two links you shared are for way older version of RN and makes impossible for us to reproduce/fix those kind of issues.
@OmarThinks please let me know if in 0.71 the issue is fixed
@cortinico As @therafibhuiyan mentioned, I and @therafibhuiyan are not the only people suffering from this tiny little bug.
I guess too many are.
Thank you so much! 😃 😃
There are two links to this error. Stackoverflow Github
Could you share those links please?
If that is the case, then this is a bug I’d like to address/handle. @OmarThinks can you share your full build log? Also can you try the same on the latest RC of
0.71.x
as I believe this issue is already solved:@cortinico It might be a problem with my setup, but if we search on the internet for the exact same issue, we’ll find out that there are many people experiencing this issue as well. Various approaches are being taken to fix this. Let’s just forget about it all and just focus on what @OmarThinks says. He just generated the template and did not add any other code to the template, just signed the keys but still got the same problem. What are you’ll gonna say about this?
Sorry for being confusing, I’ve edited my answer with a clarification. In general the CLI offers a variety of commands (like
react-native run-android
) that help you achieve most of the things you need. ForbundleRelease
there is no such command (we’re actually recently introducedreact-native build-android
so we might consider it for this scenario).In general, you should not invoke
react-native bundle
manually. If you just invoke./gradlew bundleRelease
, the bundling will be done for you. The fact that the task is failing withExecution failed for task ':app:bundleReleaseJsAndAssets'.
means that there is an underlying issue in your setup, taht you’re not fixing and you’re just circumventingThis solved it. Now I’m kinda scared to put spaces in folder paths on my machine…
@OmarThinks Ok thanks, i’m gonna try on Mac M1 and comment if the issue is solved. 😃
Thanks for the report. There is something going on with the Windows setup on 0.71 that needs to be investigated. I don’t have a Windows machine with me at the moment, I’ll follow up as soon as I have one (cc @kelset @mganandraj)
@cortinico
I will try it ASAP, sir!
I am just kinda busy now.
I will try it in a few hours, and provide feedback! 😃 😃
@therafibhuiyan I am not 100% sure what it means. Maybe he is right.
But the app crashes every time I do this. LOL! I tried lots of things. 😃
Hello! @OmarThinks Someone told me it basically binds all of my app’s artifacts and makes a release version APK ready to be deployed for production. But it seems to me that I have made a mistake by using this command.