Home > OS >  React native app failed to build while trying to bundle release
React native app failed to build while trying to bundle release

Time:08-20

I created an app which worked perfectly on debug but when i run

./gradlew assembleRelease

the build failed to complete.

Below is the error I receive.

    at ModuleResolver.resolveDependency (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:136:15)
    at DependencyGraph.resolveDependency (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\node-haste\DependencyGraph.js:231:43)
    at Object.resolve (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\lib\transformHelpers.js:129:24)
    at resolve (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33)
    at C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33)
    at processModule (C:\Users\Chifes\Desktop\app\RoGoods\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
info Run CLI with --verbose flag for more details.
?[0K
?[0K
?[0K
?[3A?[1m<?[0;32;1m=?[0;39;1m------------> 13% EXECUTING [2m 37s]?[m?[38D?[1B?[1m> :app:bundleReleaseJsAndAssets?[m?[31D?[1B> IDLE?[6D?[1B?[3A?[0K
?[31;1m> Task :app:bundleReleaseJsAndAssets?[0;39m?[31m FAILED?[39m
?[1B?[0K
?[0K
?[3A?[1m<?[0;31;1m=?[0;39;1m------------> 13% EXECUTING [2m 37s]?[m?[38D?[1B> IDLE?[6D?[1B> IDLE?[6D?[1B?[3A?[0K
?[31mFAILURE: ?[39m?[31mBuild failed with an exception.?[39m
?[0K
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
?[33m> ?[39mProcess 'command 'cmd'' finished with non-zero exit value 1

* Try:
?[33m> ?[39mRun with ?[1m--stacktrace?[m option to get the stack trace.
?[33m> ?[39mRun with ?[1m--info?[m or ?[1m--debug?[m option to get more log output.
?[33m> ?[39mRun with ?[1m--scan?[m to get full insights.

* Get more help at ?[1mhttps://help.gradle.org?[m

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.4.2/userguide/command_line_interface.html#sec:command_line_warnings

Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.

?[31;1mBUILD FAILED?[0;39m in 2m 41s
24 actionable tasks: 2 executed, 22 up-to-date
?[0K
?[0K
?[0K
?[3A?[1m<?[0;1m-------------> 0% WAITING?[m?[26D?[1B> IDLE?[6D?[1B> IDLE?[6D?[1B?[3A?[2K?[1B?[2K?[1B?[2K?[2A

The graddle drama has been there since I first installed the react native framework, and all solution to get it fixed has yielded nothing. However, like I said early, I'm able to get the app run on emulators; even on physical device, the debug apk worked perfectly.

Help is appreciated

CodePudding user response:

try this,

  1. Close metro server if is opend watchman shutdown-server
  2. for delete node-modules and re install and clear-cache watchman watch-del-all && rm -rf node_modules && npm cache clean --force && yarn install && npm start -- --reset-cache

3.after complete close the metro server, then next run this code

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

  1. finally npx react-native run-android or yarn android

CodePudding user response:

Did you try to re-bundle the entry file ?

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

Here's an issue that seems related to yours: React-Native assembleRelease fails for task ':app:bundleReleaseJsAndAssets'

  • Related