At the time of release build getting error in react native
In your scenario I think you haven't made a js bundle so please make a bundle first by using command from your project root folder
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
After that move in to your project's android directory using cd android
Before make release build make sure to clean your gradle using ./gradlew clean
And finally run this command ./gradlew assembleRelease -x bundleReleaseJsAndAssets
I have posted a full answer on this issue on here
Related
https://github.com/inspmoore/rnw_boilerplate_nav
the web is running fine but the metro bundler is crashing every time am hitting react-native run-android,
I need help desperately kindly guide me with the reason of the crash.
Screenshot of error
[UPDATE]
As per Unable to load script from assets index.android.bundle on windows, on following the instructions when I
give
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
as command am recieving
Invalid regular expression: /(.\fixtures\.|node_modules[\]react[\]dist[\].|website\node_modules\.|heapCapture\bundle.js|.\tests\.)$/: Unterminated character class
First When I created the app with react-native init project1 .
I was getting an error as below
Unable to load script from assets index.android.bundle on windows
Later I solved this issue by running following commands Stackoverflow link
mkdir android/app/src/main/assets
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
react-native run-android
But later I am getting an error like this and not able to solve, Module HMRClient is not a registered callable module (calling enable)
This is the common occurred problem, but there will not be some problem in bundling the app, Just follow some common steps and it worked for me.
Delete node_module folder and install npm
rm -rf node_modules && npm install
cd android && ./gradlew clean
then cd .. && react-native run-android
If you're developing a native module and your npm link'd folder contains a node_modules directory, this can also produce the error.
To correct for this case, you can delete the node_modules directory, re-install your project in the linked folder and use react-native start --reset-cache.
Disable hot reloading, it will work fine
This issue occurs if we enabled the production mode from dev setting by unchecking "JS Dev Mode" and then try to enable the hot reload.
Enable JS Dev Mode again will work.
Any one facing react native build issue?
I am trying to generate debug build but its crashing when the app is launched .
The exception has no useful information.
I was facing the same issue with
sudo react-native run-android
But that got resolved after upgrading RN from 0.48 to 0.55(latest Stable Version)
But the crash remain same for the apk generated using
sudo gradlew assembleDebug
The crash is similar to
https://github.com/facebook/react-native/issues/16745
please see screenshot
After so much struggle , finding solutions from different sources , I got to know that assembleDebug is not bundling by itself. So bundle it assets explicitly using below command
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
and then generate build
sudo gradlew assembleDebug
Problem
My RN application is crashing as soon as it starts (in release mode) and I can't figure out why. I'd like to build a debug version of the app that shows the error that is being encountered.
What I tried
react-native bundle --platform android --dev true --entry-file index.android.js \
--bundle-output android/app/src/main/assets/index.android.bundle \
--assets-dest android/app/src/main/res/
./gradlew assembleDebug
When I do this though, the debug build is still reading from the development server.
I have static image in my react-native app accessing via
<Image source={require("../assets/preview-full-img-title-logo#2x.png")} />
in development it is showing well but in production release APK is not showing what can be the reason? I have followed steps mention here.
https://facebook.github.io/react-native/docs/signed-apk-android.html
This is the command that did it for me:
react-native bundle --platform android --dev false --entry-file index.android.js \ --bundle-output android/app/src/main/assets/index.android.bundle \ --assets-dest android/app/src/main/res/
take a look at github issue>
I'm using react-native v0.59.9 with shrinkResources true configuration.
It makes react-native could not find the assets.
Make sure you do not set shrinkResources on android build.gradle unless the new version of react-native support it later on.
I'm using RN 0.61.2
As stated by #made-in-moon here this worked for me:
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/
Verify whether images are in ../res folder or not ${project}/android/app/src/res. If not then you need to copy images in that folder. That can be done using following react command
react-native bundle --platform android --dev false --entry-file index.android.js \ --bundle-output android/app/src/main/assets/index.android.bundle \ --assets-dest android/app/src/main/res/
Ideally, this happens in Android when images sizes are larger. Another way to avoid such issues at runtime is to optimize image sizes.
For iOS 14 one can also upgrade to the latest version of react-native 0.63.3
Check the name of the image file or try renaming.In my case, it was the name of the image. I renamed(removed '-' character) the image and it worked.