互联网停止在Android Emulator(Mac OS)上运行 [英] Internet stopped working on Android Emulator (Mac OS)

查看:131
本文介绍了互联网停止在Android Emulator(Mac OS)上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 2.3(最新).直到昨天一切都很好并且可以正常工作,今天仿真器还没有连接到数据网络.
到目前为止,我找不到任何有效的解决方案.我的Mac在Mac OS Sierra上运行,没有代理即可连接到WiFi.

I am using Android Studio 2.3(Latest). Till yesterday it was all good and working, today emulator is not connecting to the data network.
I couldn't find any solution working so far. My Mac is running on Mac OS Sierra, connected to WiFi with no proxy.

推荐答案

在Mac OS中,请转到: 系统偏好设置->网络->选择WLAN左面板->右面板上的高级-> DNS->添加新的DNS服务器;例如8.8.8.88.8.4.4( Google公共DNS )或1.1.1.11.0.0.1( Cloudflare和APNIC DNS )或其他公共DNS提供商.然后重新启动模拟器,以使更改生效.

In Mac OS go to: System Preferences -> Network -> select Wi-Fi os left panel -> Advanced on right panel -> DNS -> add new DNS server; for example 8.8.8.8 and 8.8.4.4 (Google Public DNS) or 1.1.1.1 and 1.0.0.1 (Cloudflare and APNIC DNS) or another public DNS provider. Then restart the emulator so the changes take effect.

2020年6月修改

另一种选择是在启动Android模拟器时传递dns-server参数. 根据此解决方案 https://stackoverflow.com/a/51858653/3328566 ,我更改了模拟器可执行文件的名称,创建了一个bash脚本,以使用参数-dns-server 8.8.8.8加载AVD.

Another option is to pass dns-server params when start Android emulator. According with this solution https://stackoverflow.com/a/51858653/3328566, I changed the emulator executable name and I created a bash script to load the AVD with param -dns-server 8.8.8.8.

在您的Android SDK默认文件夹/Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator

In your Android SDK default folder /Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator

  1. 将二进制文件emulator重命名为emulator_original
  2. 创建一个名为emulator的bash脚本,其中包含:
  1. Rename the binary emulator to emulator_original
  2. Create a bash script named emulator that contains:

#!/bin/bash /Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator_original -dns-server 8.8.8.8 $@

#!/bin/bash /Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator_original -dns-server 8.8.8.8 $@

  1. 使用chmod +x emulator
  2. 更改脚本权限
  1. Change the script permissions with chmod +x emulator

现在,您可以正常地从Android Studio启动AVD

Now, you can start AVD from Android Studio normally

在这种情况下,您不需要在系统偏好设置"中设置DNS服务器.您只为模拟器设置了DNS服务器,从而避免了其他问题

In this case, you don't need to set DNS server in System Preferences. You are setting the DNS server only for the emulator, avoiding other problems

这篇关于互联网停止在Android Emulator(Mac OS)上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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