如何将我的Android模拟器连接到互联网,例如使用浏览器?我已经找到了很多关于如何通过代理连接的建议,但这里不是这样,我的机器(Windows 7)是直接连接到路由器的。


当前回答

我解决了这个问题,我禁用了所有的网络连接,除了我正在使用的wifi连接,然后将剩余的启用连接的属性设置为静态分配的DNS地址。(没有DHCP)这是Win7 64bit

其他回答

我没有使用代理……然而,我正在使用一个脚本…在这附近。我在公司的防火墙后面

(编辑) 对于最新版本的Android Studio,你需要使用的模拟器不再在~/Library/Android/sdk/tools文件夹中,而是在~/LibraryAndroid/sdk/emulator中。 如果在尝试下面的解决方案时,您会得到以下消息“PANIC:缺少'x86' CPU的模拟器引擎程序。,然后请参考https://stackoverflow.com/a/49511666更新您的bash环境。

操作系统:Mac OS X El Capitan

IDE: Android Studio 2.2

由于某些原因,我无法通过工作时的AVD访问互联网(可能是代理或网络配置问题)。 对我来说,诀窍是在命令行启动我的AVD,并手动提供谷歌公共DNS 8.8.8.8。

在你的终端中,进入Android sdk的文件夹工具,找到“模拟器”程序:

cd ~/Library/Android/sdk/tools

然后检索avd的名称:

emulator -list-avds

它会返回如下内容:

Android_Wear_Round_API_23
Nexus_10_API_22
Nexus_5X_API_22
Nexus_5X_API_24
Nexus_9_API_24

然后按以下指示启动您想要的AVD:

emulator -avd NameOfYourDevice -dns-server 8.8.8.8

您的AVD已经启动,您应该可以使用互联网了。

环境:Windows 7 64位

在我的例子中,我必须在verbose模式下运行模拟器(emulator -verbose -avd Nexus_6_API_25)来找出模拟器检测到两个DNS服务器的事实,如下所示。

模拟器:找到2个DNS服务器:192.168.3.227 192.168.1.1

在检测到的两个DNS服务器中,只有一个有互联网连接,这是模拟器无法上网的原因。

为了成功连接android模拟器到互联网,没有互联网连接的DNS服务器必须从控制面板\网络和互联网\网络连接中禁用

如果您在SDK管理器的工具->选项下是代理,则不要配置代理设置。 当你从命令行运行时,添加-http-proxy:

emulator.exe -avd YOUR_AVD_NAME_HERE -http-proxy PROXY:PORT

为我工作。

it appears there might be a few reasons why there might be no internet connection for an emulator, in my case i was working from home where i have a wireless connection then came into the office and plugged in direct, however although my wireless connection was disconnected it was not disabled resulting in no emulator connection. my understanding is that when it starts up it looks for a network adapter and if there is any conflict here it might result in no internet connection. to resolve go to Start > Settings > Network Connections right click on Wireless Network Connection (if you are not using wireless) and select disable