I am building a react native app. Yesterday i have ran successfully cd android && ./gradlew bundleRelease. After that, I have tried to run react-native run-android but got this error: Unable to load script. Make sure you're either running a Metro (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
How to make it work again normally in debug mode?
I fixed by changing targetSdkVersion:28 to 26 in build.gradle file
Maybe try to run npm start -- --reset-cache for the Metro Bundler and then in another terminal try to run react-native run-android
Related
I ejected an expo project and tried running npm start and npx react-native run-android. The bundler runs and shows this
To reload the app press "r"
To open developer menu press "d"
The app is installed in the emulator, but shows the following error.
unable to load script. make sure you're either running a metro
server (run 'react-native start') or that your bundle
'index.android.bundle' is packaged correctly for release.
The emulator is able to reach the host machine IP address in the browser.
I tried the following solutions.
Run npm start or react-native start in the root directory of your project before react-native run-android
android:usesCleartextTraffic="true"
Changing port
Nothing helped me. What could be the issue?
Hello have you experienced this error after generate an apk with command ./gradlew assembleDebug ??
I just see this error after download the apk on my android phone...
"react-native": "~0.61.5",
The apk that you built is still debug version.
./gradlew assembleDebug
Thats why it still need the metro server to debug and run normally.
If you want to test out a release version of the apk you need to build and run the apk in release mode:
Either, build a signed apk
https://reactnative.dev/docs/signed-apk-android
or
Let react native run a release variant on your device(you may still need metro server)
react-native run-android --variant=release
If the above command doesn't work try:
react-native run-android --configuration=release
Recently I tried to create and run in windows 10 by referring the link https://reactnative.dev/docs/environment-setup. I too face same issue and I figure out that this is because by default mobile device try to search build in port 8081. So I gave this command to change the port and run
npx react-native run-android --port=1234 and it worked.
npx react-native run-android --port=1234
go to android folder ./gradlew clean
and go back to your project
and npx run react-native run-android
I had to add the Android SDK path to my .bash_profile or .zshrc:
export ANDROID_SDK=/Users/<username>/Library/Android/sdk export PATH=/Users/<username>/Library/Android/sdk/platform-tools:$PATH
I am getting these errors ;
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
Open up a new tab in the terminal and in your project folder type react-native-start and then go back to the other tab and run your project by typing react-native run-android
By using react-native start you will see the metro bundler starting up and running. If you want to clear the metro cache then type the below in your project directory
react-native start --reset-cache
I run react-native application in emulator but when I run npx react-native run-android --no-jetifier, run stuck and do nothing:
My emulator:
How to fix it?
It won't work if there is a lib that requires jetifier eg. react-native-gesture-handler.
If there is no lib as such then delete the node_modules and npm install and try again.
"react": "16.8.6",
"react-native": "0.60.3"
React Native Version mismatch error after run new vesion app
I have 2 RN projects. And when I use reactotron app with the first project (RN 0.59) and open a new one without stopping reactotron then this error happens. Restarting reactotron helped me.
react-native 0.60.0 new version
use the command
react-native start
or
npm start
or
react-native run-android
Use this :
First of all uninstall app from your device
After this clean gradlew
close the Metro bundler and also terminal
Open terminal in the root of your project directory and run
npm start -- --reset-cache
or
yarn start -- --reset-cache
Open another terminal in the root of your project directory and run
react-native run-android
OR
Restart the system
Hope it will work