简体   繁体   English

如何从Android Studio模拟器连接到localhost

[英]How to connect to localhost from Android Studio emulator

I am trying to test web application in Android 2.3.3 browser. 我试图在Android 2.3.3浏览器中测试Web应用程序。 Connection using http://10.0.2.2 results "web page is unavailable" . 使用http://10.0.2.2连接结果“网页不可用” Nothing found in Android Studio documentation . Android Studio 文档中找不到任何内容

Does anyone run into the same problem? 有没有人遇到同样的问题? How did you solve it? 你是怎么解决的?

You're going to need to connect to your computer's IP. 您将需要连接到计算机的IP。

If you're on Windows open CMD and type ipconfig this will give you your local IP. 如果你在Windows上打开CMD并键入ipconfig,这将为您提供本地IP。

If you're on Linux or OSX open terminal and use the ifconfig command. 如果您使用的是Linux或OSX开放终端并使用ifconfig命令。

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. 由于模拟器是完整的Android设备,因此它具有自己的网络,并且不使用与您的计算机相同的主机文件。 Along with its own IP. 随着自己的IP。

Edit: Grammar fix. 编辑:语法修复。

I use my local ip for that ie 192.168.0.1 and it works. 我使用我的本地IP,即192.168.0.1,它的工作原理。 Verify your local IP. 验证您的本地IP。

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

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