Home > database >  I am not able to connect to metro in react-native?
I am not able to connect to metro in react-native?

Time:03-31

I App is not able to connect to metro . firstly it was running but now its stop working and giving below error :

Anyone help regarding that error . enter image description here

CodePudding user response:

You can try below answer's :

  1. unable to load script from assets index.android.bundle

adb reverse tcp:8081 tcp:8081

2)(in project directory)

mkdir android/app/src/main/assets


 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 run-android

You can automate the above steps by placing them in scripts part of package.json like this:

"android-linux": "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 run-android"

Then you can just execute npm run android-linux from your command line every time.

3)Try to upgrading targetSdkVersion to 28

Also there are some more answer's you can access it thorugh this change bundle location

Input ipv4 / inet address got from above following with port number(XXX.XXX.XXX.XXX:8081) shown like above image (eg ipv4/inet = 192.168.1.108)

  • Related