I've read that disabling the dev mode in Android can help speed up some of the issues with the Android emulator as it keeps not responding at the moment. How do I disable dev mode? I can't find any bool value or anything anywhere in the react native files.
You can also try running npm start , then press d to switch the current mode, then stop npm by ctr+c and then run again exp start you will find the enhancement feature became On and the mode became production.
Go to your android settings and clear app data and cache and reload the app remote debugging will be turned off.
In App Developer MenuOn Android emulator, you need to press command + M. Debug JS Remotely − Used for activating debugging inside browser developer console. Enable Live Reload − Used for enabling live reloading whenever your code is saved. The debugger will open at localhost:8081/debugger-ui.
If you open the menu in react-native apps (F2 or rage shake) and choose dev options, there is option to switch off dev mode along with other options like live reload
I preferred the way to build apk with a simple gradle command line. I need to build a app-preprod.apk with bundle react native JS and turn off its dev mode to set some different api hostname settings from release build.
After looks over google and stackoverflow, I ended up to find PROJECT_PATH/android/app/react.gradle
, and it turns out react will only turn off the dev mode when android build variants name contains "release".
// Set up dev mode
def devEnabled = !targetName.toLowerCase().contains("release")
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
} else {
commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
}
So I just refactor the devEnabled follow my custom setting devInXxx
def devEnabled = config."devIn${targetName}" == false ? false : !targetName.toLowerCase().contains("release")
And set build type variants dev mode to false in PROJECT_PATH/android/build.gradle
project.ext.react = [
bundleInPreprod: true,
devInPreprod: false]
To clean the build, remove all files under "PROJECT_PATH/android/app/build" and run gradle assemble the build variant only by
PROJECT_PATH/android$ ./gradlew assemblePreprod
which will build the app-preprod.apk, which bundled js and turn dev mode off. Normally under the folder PROJECT_PATH/android/app/build/output/apk/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With