简体   繁体   English

如何从VS Android Emulator连接到localhost

[英]How to connect to localhost from VS Android Emulator

I am attempting to connect to the localhost of the machine from which I am booting a VS Android Emulator. 我正在尝试连接到我正在启动VS Android模拟器的机器的本地主机。 I am able to successfully connect to the IIS Server when the Android version is Kitkat. 当Android版本是Kitkat时,我能够成功连接到IIS服务器。 However, I fail to connect when the VS Android Version is Lollipop or Marshmallow. 但是,当VS Android版本是Lollipop或Marshmallow时,我无法连接。 The way I am connecting to the localhost is typing http://169.254.80.80 in the browser of the Emulator. 我连接到localhost的方式是在模拟器的浏览器中输入http://169.254.80.80 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. 根据http://developer.android.com/tools/devices/emulator.html#networkaddresses,我应该能够使用IP地址10.0.2.2连接到localhost。 However, this IP address doesn't seem to work for me. 但是,这个IP地址似乎对我不起作用。

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). http://developer.android.com/tools/devices/emulator.html#networkaddresses上指定的网络地址不适用于Android的Visual Studio模拟器(除了最后一个,这是标准的本地主机IP地址) )。

The address 169.254.80.80 is expected to work as a loopback to the host. 地址169.254.80.80预计将作为主机的环回工作。 There seems to be a bug regarding connectivity back to the host using that address on images running Lollipop (21) and above. 似乎存在关于在运行Lollipop(21)及更高版本的图像上使用该地址连接回主机的错误。 I have logged a bug internally for this. 我已经在内部记录了一个bug。

VS studio Emulator work very fine and fast VS studio Emulator工作非常精细和快速

see the screen shot that how you can connect VS Emulator to localhoat 请参阅屏幕截图,了解如何将VS Emulator连接到localhoat

在此输入图像描述

The previous answer is perfect but Android studio 3+ emulator need to add IP and port on proxy under setting. 之前的答案是完美的,但Android studio 3+模拟器需要在设置下添加代理上的IP和端口。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM