如何从 Android Studio 模拟器连接到本地主机 [英] How to connect to localhost from Android Studio emulator

查看:167
本文介绍了如何从 Android Studio 模拟器连接到本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Android 2.3.3 浏览器中测试 Web 应用程序.使用http://10.0.2.2 的连接结果网页不可用".Android Studio 文档中未找到任何内容.

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?

推荐答案

您将需要连接到计算机的 IP.

You're going to need to connect to your computer's IP.

如果您使用的是 Windows,请打开 CMD 并输入 ipconfig,这将为您提供本地 IP.

If you're on Windows open CMD and type ipconfig this will give you your local IP.

如果您使用的是 Linux 或 OSX,请打开终端并使用 ifconfig 命令.

If you're on Linux or OSX open terminal and use the ifconfig command.

由于模拟器是一个完整的 Android 设备,它有自己的网络,并且不使用与您的机器相同的主机文件.加上自己的IP.

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.

语法修复.

这篇关于如何从 Android Studio 模拟器连接到本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆