How can I forward my localhost IP-Address to an Android Emulator?

前端 未结 3 715
逝去的感伤
逝去的感伤 2020-12-02 17:41

I know it is possible to forward a port from my develop machine to an Android emulator, but how is this done? I\'ve found the solution on the android-developers site, but I

3条回答
  •  孤街浪徒
    2020-12-02 18:12

    You can use the adb forward command to set up arbitrary port forwarding — forwarding of requests on a specific host port to a different port on an emulator/device instance. Here's how you would set up forwarding of host port 6100 to emulator/device port 7100:

    adb forward tcp:6100 tcp:7100
    

    For example run NanoHTTPD web server on the AVD and then execute this command on the computer:

    adb forward tcp:8080 tcp:8080
    

    Open the browser on the computer and navigate the below address:

    localhost:8080
    

    http://developer.android.com/tools/help/adb.html#forwardports

提交回复
热议问题