Is there an easy way to setup the android emulator to access the LAN of the host machine?

后端 未结 4 808
生来不讨喜
生来不讨喜 2020-12-09 18:07

I would like to access a web service provided by one of the machines on my LAN from the android emulator.

If the service was running on the same machine where the em

4条回答
  •  醉话见心
    2020-12-09 18:58

    as of 2018-08 it seems the "it just works (TM)" certificate has been revoked

    here is what I needed to access a server in my local network:

    host ip (my pc): 192.168.15.102/24 
          server ip: 192.168.200.33/24
    

    create a port forwarding rule in an elevated command prompt on host using netsh

    netsh interface portproxy add v4tov4 listenport=80 connectport=80 connectaddress=192.168.200.33
    

    start the mobile device emulator and browse to 10.0.2.2 (as mentioned in the documentation):

    10.0.2.2 Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)

提交回复
热议问题