How to connect to localhost from VS Android Emulat

2020-02-06 05:15发布

问题:

I am attempting to connect to the localhost of the machine from which I am booting a VS Android Emulator. I am able to successfully connect to the IIS Server when the Android version is Kitkat. However, I fail to connect when the VS Android Version is Lollipop or Marshmallow. The way I am connecting to the localhost is typing http://169.254.80.80 in the browser of the Emulator. As per http://developer.android.com/tools/devices/emulator.html#networkaddresses I should be able to connect to localhost using the IP address 10.0.2.2. However, this IP address doesn't seem to work for me.

回答1:

The network addresses specified on http://developer.android.com/tools/devices/emulator.html#networkaddresses will not work for the Visual Studio Emulator for Android (well, except the very last one, which is the standard localhost IP address).

The address 169.254.80.80 is expected to work as a loopback to the host. There seems to be a bug regarding connectivity back to the host using that address on images running Lollipop (21) and above. I have logged a bug internally for this.



回答2:

VS studio Emulator work very fine and fast

see the screen shot that how you can connect VS Emulator to localhoat



回答3:

The previous answer is perfect but Android studio 3+ emulator need to add IP and port on proxy under setting.