How do I load React Native Project in Android Studio with an emulator?

Viewed 40

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.

enter image description here

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

1 Answers

Steps to run react-native project in Android Studio:

  1. npm start --reset-cache (it will pop-out a terminal for js-bundling).
  2. open project root android folder in android studio.
  3. wait until build project && if you get any error then resolve it.
  4. after successful build project in android studio "Run" your App. (In case you want to use break-points "Debug-Run" your App.).
  5. Done
Related