I know that similar questions have been asked before, but my problem is new only after installing Android Studio 2.3, the latest version in March 2017. I have several years experience developing Android applications, and I have never encountered this problem before. After upgrading to version 2.3 of Android Studio, my emulator is no longer able to access the internet. I even uninstalled/reinstalled Android Studio 2.3 from scratch and created a new emulator, and I am still getting the same error. This is not an app problem. I can't even access the internet from Chrome, and I wasn't having this problem last week. The message that I get says that the server DNS address could not be found -- DNS_PROBE_FINISHED_BAD_CONFIG. The only thing that has changed on my computer in the last week is the new version of Android plus possibly updates to Windows 10. And yes, my computer has access to the internet. Below is an image of my emulator when I try to use Chrome to search for "Google".


当前回答

MacOS解决方案,不为整个机器使用自定义DNS

步骤1

找到Android Studio在Android SDK中使用的模拟器可执行文件,并将其重命名为simulator -original。

我的位于/usr/local/share/android-sdk/emulator/emulator,但它可能会根据个人设置而有所不同。

步骤2

在包含以下命令的原始文件(或使用您选择的DNS服务器)的位置添加一个名为emulator的新文件。

#!/bin/bash
$0-original "$@" -dns-server 8.8.8.8

步骤3

使新的模拟器文件可执行。

chmod +x emulator

步骤4

使用Android Studio重新启动模拟器。

其他回答

只需要用另一个目标API重新创建模拟器就可以了

我在升级后遇到了同样的问题。在模拟器中打开Chrome浏览器后,无法再访问google.com。

我在SO上找到了一篇文章,指出问题是模拟器试图使用一个断开连接的网络适配器。对我来说,这个问题是在我连接到局域网时发生的。禁用无线局域网适配器解决了这个问题。

禁用适配器。

导航到网络连接 找到适配器 右键单击并选择禁用

我观察到的是,当你切换wifi连接时,android模拟器正在运行。它无法连接到新的wifi。

一个简单的解决方案是重新启动android模拟器。

首先尝试“冷启动”模拟器,建议在这里。 如果冷启动不起作用,请尝试将网络的DNS地址更改为8.8.8.8(谷歌的DNS)或其他您喜欢的DNS:

MacOSX:

打开“系统首选项” 点击“网络” 选择你的电脑所连接的网络,然后点击“高级” 选择“DNS”,选择“+”按钮,输入“8.8.8.8”(谷歌的DNS),或者如果你喜欢OpenDNS,“208.67.222.222” 选择“确定”和“应用”

Windows和Linux:

https://developers.google.com/speed/public-dns/docs/using


之后,关闭模拟器并重新启动它。

我有visual studio 2017,这简单的几次点击已经修复了Android模拟器的互联网问题。