如何从Android Studio模拟器连接到localhost [英] How to connect to localhost from Android Studio emulator
问题描述
我正在尝试在Android 2.3.3浏览器中测试Web应用程序. 使用 http://10.0.2.2 进行的连接网页不可用" .在 Android Studio 中没有找到文档.>
有人遇到同样的问题吗?您是如何解决的?
您将需要连接到计算机的IP.
如果您使用的是Windows,请打开CMD并键入ipconfig,这将为您提供本地IP.
如果您使用的是Linux或OSX开放终端,请使用ifconfig命令.
由于仿真器是完整的Android设备,因此它具有自己的网络,并且不会使用计算机所具有的相同主机文件.连同自己的IP.
语法修复.
I am trying to test web application in Android 2.3.3 browser. Connection using http://10.0.2.2 results "web page is unavailable". Nothing found in Android Studio documentation.
Does anyone run into the same problem? How did you solve it?
You're going to need to connect to your computer's IP.
If you're on Windows open CMD and type ipconfig this will give you your local IP.
If you're on Linux or OSX open terminal and use the ifconfig command.
Since the emulator is a full Android device it has its own network and doesn't use the same hosts file that your machine has. Along with its own IP.
Edit: Grammar fix.
这篇关于如何从Android Studio模拟器连接到localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!