react-native build a standalone app in dev mode - reactjs

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.

Related

Metro bundler crashing

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

Build failed for task ':app:bundleReleaseJsAndAssets' in react native

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

React Native - Debug build displays 'Welcome to React Native' screen instead of home screen

My Application is working fine with the release build, but If I use the debug build, it always shows 'Welcome to React Native' screen when I start my Application & it is not proceeding further. I am not sure how to get rid of it.
Go to the root project folder/directory and then run this:
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 Crash Undefined is not an object (Evaluating 'Sn[e]')

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

React Native Android: Static Image is not showing in production released apk

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.

Resources