'App launch crash -- unable to load script

I generated signed release universal apk for React Native 0.67.4 app and the release app installed on real device keeps crashing with the following error:

04-08 12:20:53.828  4299  4430 E AndroidRuntime: FATAL EXCEPTION: create_react_context
04-08 12:20:53.828  4299  4430 E AndroidRuntime: Process: com.xyz_app6, PID: 4299
04-08 12:20:53.828  4299  4430 E AndroidRuntime: java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(Unknown Source:2)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.bridge.JSBundleLoader$1.loadScript(Unknown Source:10)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(Unknown Source:18)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.o.s(Unknown Source:177)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.o.d(Unknown Source:0)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at com.facebook.react.o$f.run(Unknown Source:68)
04-08 12:20:53.828  4299  4430 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:929)

The android studio is 2021.1.1 patch 2 and here is the output of ./gradlew --version:

% ./gradlew --version

------------------------------------------------------------
Gradle 7.4.1
------------------------------------------------------------

Build time:   2022-03-09 15:04:47 UTC
Revision:     36dc52588e09b4b72f2010bc07599e0ee0434e2e

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.12 (Eclipse Foundation 11.0.12+7)
OS:           Mac OS X 11.2 x86_64

The package was built with /gradlew assembleRelease following the standard signing config for React Native. Hermes enabled and ProGuard true in config. What is missing with the release package?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source