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?
Related
OS: Linux Ubuntu
CLI or Expo: CLI
RN Version: 0.70.6
I start my React Native project with the following commands:
yarn start
yarn react-native run-android
It works when a real device connected to my PC and the project starts on my device. But it does not work with an Android Emulator.
When I try with an emulator:
yarn start command shows usual outputs. No error, nothing. Seems to work correctly
yarn react-native run-android also same. Build successful. No error or warning.
adb devices command shows my emulator correctly.
But emulator does not start my project. I can see my project icon on the emulator. When I double click to my project, I just see a blank screen for one second or less and it closed again.
When i try to reload metro using r command on terminal it says no apps connected.
I think the emulator builds the app but not connect to metro properly. I don't know why. I cannot see any error or warning messages.
I tried ./gradlew clean and delete node_modules and install but it didn't work.
I also tried yarn start --port 8081 but it also didn't work.
EDIT: For testing purpose, I created a new project with `npx react-native init AwesomeProject' and it works on the emulator. So I think the problem is only about the other project.
SOLUTION:
In my case it was because of Flipper version. When I changed it from 0.125 to 0.144 my project started on an android emulator properly.
Here is the link where i found the solution:
react-native-issue-in-github
My react native project is failing to launch in Android Studio. I am running Metro (ran command line 'npx react-native start' in the project root directory) but the below message appears.
I am able to launch the project with no issues using terminal with the command line 'npx react-native run-android'.
Can someone please assist? I would like to run my project using the emulator in Android Studio and not via terminal.
Error when debugging:
E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:234)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:29)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:263)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1293)
at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1023)
at java.lang.Thread.run(Thread.java:920)
D/CompatibilityChangeReporter: Compat change id reported: 171***; UID 10***; state: ENABLED
I/FA: Tag Manager is not found and thus will not be used
W/unknown:ReconnectingWebSocket: Couldn't connect to "ws://localhost:8081/message...", will silently retry
Steps to run react-native project in Android Studio:
npm start --reset-cache (it will pop-out a terminal for js-bundling).
open project root android folder in android studio.
wait until build project && if you get any error then resolve it.
after successful build project in android studio "Run" your App. (In case you want to use break-points "Debug-Run" your App.).
Done
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 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
I am a starter of React-native tho I am having trouble with debugging. Program is successfully installing apk to emulator but can not render the component. Whenever I double press 'R' (I am on windows) it throws following error
Try:
cd YourProject
react-native run-android
react-native start