How to connect to localhost from Android Studio emulator

僤鯓⒐⒋嵵緔 提交于 2019-12-04 03:36:42

问题


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?


回答1:


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.




回答2:


I use my local ip for that i.e. 192.168.0.1 and it works. Verify your local IP.



来源:https://stackoverflow.com/questions/42904584/how-to-connect-to-localhost-from-android-studio-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!