简体   繁体   English

如何将Android模拟器连接到localhost服务器?

[英]How do I connect an Android Emulator to localhost server?

I have an ASP.NET/Azure application running on http://localhost:4617 . 我有一个在http://localhost:4617上运行的ASP.NET /Azure应用程序。 I would like to debug a REST call made from an Android emulator. 我想调试从Android模拟器发出的REST调用。 Related SO threads seem to indicate that you should use 10.0.2.2 . 相关的SO线程似乎表明您应该使用10.0.2.2 I've tried several variations like http://10.0.2.2:4617 , but none seem to work. 我尝试了几种变体,如http://10.0.2.2:4617 ,但似乎都没有。 Any other suggestions? 还有其他建议吗?

If I do ping localhost on my machine, it returns Reply from ::1: time<1ms which seems to have something to do with an ipV6 address, but I'm not sure how this is related. 如果我在我的机器上ping localhost ,它会Reply from ::1: time<1ms返回Reply from ::1: time<1ms这似乎与ipV6地址有关,但我不确定这是如何相关的。

If the local host is running on your desktop than that is the problem. 如果本地主机在您的桌面上运行而不是问题。 When you type http://10.0.2.2 it tries to connect to the Android emulator local host. 当您键入http://10.0.2.2时,它会尝试连接到Android模拟器本地主机。

What you need to do is find your computer IP address (you can use google for it). 您需要做的是找到您的计算机IP地址(您可以使用谷歌)。 Then once you have it type that into your android emulator browser and it should work 然后,一旦你有它进入你的Android模拟器浏览器,它应该工作

I was able to figure this out. 我能够弄清楚这一点。 If you're running an Azure server-emulator, then you need to run Visual Studio with administrator privileges. 如果您正在运行Azure服务器模拟器,则需要以管理员权限运行Visual Studio。 If you don't, then it will not bind correctly to the local host. 如果不这样做,则它将无法正确绑定到本地主机。

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

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