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


当前回答

环境: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服务器必须从控制面板\网络和互联网\网络连接中禁用

其他回答

我也有类似的问题。我安装了一个需要INTERNET权限的应用程序(并使用了它),然后突然就工作了。

朋友们,还要检查一下你是否在某个地方没有通过VPN连接,因为它也会干扰互联网连接。

blacharnia

我不确定这是否是你的问题,但这是我解决我的问题的方法。

在启动模拟器时,我总是有这个“没有找到DNS服务器”的错误,并对谷歌进行了大量的研究,但无济于事。不管怎样,我在某个地方发现了一个帖子(再也找不到它了),它说nic的数量,DNS条目的数量会影响模拟器。此外,知道模拟器使用Windows API函数(GetNetworkParams())来解析DNS条目,我不能依赖于% Windows %\System32\Hosts文件。

然而,我在nic属性中(在Windows 7上)发现我指定了一个静态IP,但没有DNS条目。因此,我从路由器获取了DNS条目,并将它们插入NICs属性中。我重新启动模拟器,现在它正在使用正确的DNS条目!

我现在可以使用模拟器的互联网连接,它的工作效果非常好!

希望能有所帮助!

I have Mac OS X 10.7.2, Eclipse Helios Service Release 2. I also work via Proxy and my IP settings are via DHCP. I solved this issue firstly using this article http://www.gitshah.com/2011/02/android-fixing-no-internet-connection.html, then I removed Emulator settings and just go to Run->Run Configurations->Target->Additional Emulator Command Line Options and type there -http-proxy xxx.xx.111.1:3128 . Also I would like to say that when I typed also a DNS like this: -dns-server xxx.xx.111.1 -http-proxy xxx.xx.111.1:3128 it did not work, but when I removed DNS it worked. Also I would like to note, that Additional Emulator Command Line Options are not visible without scrolling to the bottom of that window. I also want to note, that when you change emulator options, all apps will work. But If you write Additional Emulator Command Line Options, you need to write them every time for every app target in Run Configurations.

确保飞行模式是关闭的。我一直试图连接互联网很长一段时间,才意识到哪里出了问题。

在Android模拟器中,打开飞机模式,然后再关闭,对我来说很管用。