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".


当前回答

请点击下面的链接。

https://developer.android.com/studio/run/emulator-networking

打开模拟器,点击更多…,然后单击“设置和代理”。从这里,您可以定义自己的HTTP代理设置。

输入主机名 执行> cmd > hostname

最后,通过chrome浏览器或谷歌检查模拟器内部的网络访问。

注意:经常擦数据就会清除这个问题。请遵循所有步骤

其他回答

正如@osama buzdar所指出的,模拟器首先查看的DNS设置可能在/etc/resolv.conf中指定。在我的情况下,macOS Catalina 10.15.7,该文件中有2个地址:第一个是IPv6,第二个是IPv4,由于某种原因,模拟器可能在IPv6上有问题。

然后我编辑文件(sudo vi /etc/resolv.conf),并将IPv4移到文件的第一个条目,在IPv6之前。重新启动模拟器,它工作了。

对我来说,我在模拟器中打开连接设置,断开了Android WiFi。然后在这个里面,我按了忘记连接。现在再次连接到相同的WiFi解决了这个问题。我认为这是解决问题的最快方法!

我在升级到SDK 2.3的旧Stack Overflow线程上找到了一个临时解决方案-现在没有模拟器具有连接性。注意,本文讨论的是Android SDK 2.3,而不是Android Studio 2.3。问题似乎是模拟器无法找到我的计算机当前正在使用的DNS,临时的解决方法是从命令行启动模拟器并指定DNS服务器。无论当时发生了什么问题,一定会在最新版本的Android Studio中重新出现。

下面概述的临时解决方案修复了模拟器访问internet的问题。但是,它并没有修复试图运行Android设备监视器时发生的问题。这样做仍然会使模拟器脱机,如上所述。

注意,在sdk中有两个名为“模拟器.exe”的文件——一个在sdk\tools下,另一个在sdk\emulator下。任何一个都可能在下面工作,但我使用sdk\emulator下的一个。

第一步是找到SDK的位置。假设用户名为“jdoe”,并且在Windows上默认安装了Android Studio,那么SDK很可能在

C:\Users\jdoe\AppData\Local\Android\sdk

第二步是确定要运行的AVD(模拟器)的名称。命令

C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -list-avds

将显示avd的名称。在我的计算机上,它只显示了一个,Nexus_5X_API_25。

要使用指定的DNS服务器从命令行启动模拟器,可以使用如下命令:

C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -avd Nexus_5X_API_25 -dns-server 8.8.8.8

在此例中,8.8.8.8为谷歌公共域名服务器。

如果创建适当的环境变量并编辑PATH环境变量,则可以缩短上面的命令,但我建议在这样做时要谨慎。

对我来说,在OSX上,这是因为使用第三方VPN解决方案…它安装了一些avd和Genymotion无法通过的网络钩子。必须卸载它才能正常工作。在某些网络上工作得很好,而在其他网络上则不行……很奇怪…

提醒:如果您打开计算机上的VPN系统,Android模拟器的互联网连接将无法工作。