How to modify IP & port use react-native Android?

后端 未结 5 640
花落未央
花落未央 2020-12-16 08:27

I used the react-native Android demo project AwesomeProject and within the project I executed:

react-native start

In a second terminal:

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 09:15

    There is a small work around for this. Anyone running this on a physical device(or even otherwise) can restart their adb session using a different port.

    eg.

    react-native start --port=1234
    

    On a different cmd/terminal window.

    react-native run-android
    

    After which I am greeted by these messages.

    BUILD SUCCESSFUL
    
    Total time: 22.589 secs
    Running C:\SDK/platform-tools/adb -s VY0025160560725694 reverse tcp:8081 
    tcp:8081
    

    This runs it on default reverse port of 8081, which is blocked by McAfee.

    Work around:

    adb reverse tcp:8081 tcp:1234
    

    Try it out. It works for me.

    Note: You may have to kill and re-open the app.

    Currently I am unable to provide an answer for an emulated device since I do not have one installed on my system. But the symantics should be similar.

    Note: This may break automatic code updates using watchman.

提交回复
热议问题