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

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

问题描述

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

解决方案

在 Mac OS 中转到:系统偏好设置 -> 网络 -> 选择 Wi-Fi os 左侧面板 -> 右侧面板上的高级 -> DNS -> 添加新的 DNS 服务器;例如 8.8.8.88.8.4.4 (

2020 年 6 月编辑

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

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

  1. 将二进制emulator重命名为emulator_original
  2. 创建一个名为 emulator 的 bash 脚本,其中包含:

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

  1. 使用 chmod +x emulator
  2. 更改脚本权限

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

在这种情况下,您无需在系统偏好设置中设置 DNS 服务器.您仅为模拟器设置 DNS 服务器,避免其他问题

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.

解决方案

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.

Edited jun/2020

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.

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

  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 $@

  1. Change the script permissions with chmod +x emulator

Now, you can start AVD from Android Studio normally

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天全站免登陆