在 Android 模拟器上启用 WiFi
如何在Android模拟器上启用WiFi?我试图找到这个,但每个人都将 WiFi 与 3G 混淆了。
How to enable WiFi on Android emulator? I have tried to find this but everyone is confusing WiFi with 3G.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您使用的 API 级别低于 25,则 Wifi 在模拟器上不可用。
更多信息:
https://developer.android.com/studio/run/emulator.html#wifi
Wifi is not available on the emulator if you are using below of API level 25.
More Information:
https://developer.android.com/studio/run/emulator.html#wifi
显然事实并非如此,我也没想到会如此。然而,Ivan 提出了一个很好的可能性,但 Android 人员却没有注意到。
模拟器的目的是什么?模仿,对吧?我不明白为什么出于测试目的 - 假设测试人员了解限制 - 模拟器可能不会添加 Wifi 模拟器。
例如,它可以通过使用主机的底层互联网连接来模拟 WiFi 访问。显然,测试 WPA/WEP 差异没有意义,但至少它可以通过 WiFi 切换访问。
或者某种模拟器插件,其中有一个基本的 WiFi 模拟器,可以通过底层连接模拟 WiFi 访问,然后通过配置,它可以通过提供假 WiFi 网络列表及其相应的匹配假密码来模拟 WPA/WEP针对可配置的凭据列表。
毕竟,我们的想法是在模拟器上进行初始测试,然后转移到实际设备上。
Apparently it does not and I didn't quite expect it would. HOWEVER Ivan brings up a good possibility that has escaped Android people.
What is the purpose of an emulator? to EMULATE, right? I don't see why for testing purposes -provided the tester understands the limitations- the emulator might not add a Wifi emulator.
It could for example emulate WiFi access by using the underlying internet connection of the host. Obviously testing WPA/WEP differencess would not make sense but at least it could toggle access via WiFi.
Or some sort of emulator plugin where there would be a base WiFi emulator that would emulate WiFi access via the underlying connection but then via configuration it could emulate WPA/WEP by providing a list of fake WiFi networks and their corresponding fake passwords that would be matched against a configurable list of credentials.
After all the idea is to do initial testing on the emulator and then move on to the actual device.
截至目前,随着 Android 模拟器的修订版 26.1.3,它终于可以在 API 25 的映像 v8 上实现。
如果模拟器是在升级到最新的 API 25 映像之前创建的,则您需要擦除数据,或者根据需要删除并重新创建映像。
来自 https://developer.android.com/studio/releases/ emulator.html#26-1-3
As of now, with Revision 26.1.3 of the android emulator, it is finally possible on the image v8 of the API 25.
If the emulator was created before you upgrade to the latest API 25 image, you need to wipe data or simply delete and recreate your image if you prefer.
from https://developer.android.com/studio/releases/emulator.html#26-1-3
(这里重复我在别处的回答。)
理论上,linux(android底层的内核)有mac80211_hwsim 驱动程序,模拟 WiFi。它可用于设置多个 WiFi 设备(一个接入点和另一个 WiFi 设备等),从而组成一个 WiFi 网络。
它对于在 Linux 下测试 WiFi 程序很有用。有可能,即使在 用户模式 linux 或其他带有 linux 的隔离虚拟“盒子”下也是如此。
理论上,这个驱动程序可以用于在没有真正的 WiFi 设备(或不想使用它)的 Android 系统中进行测试,也可以在某种 Android 模拟器中进行测试。也许,人们可以设法在 android-x86 中使用此驱动程序,或者在 VirtualBox 中运行的 android-x86 中进行测试。
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.
如果您使用 API 24 或更早版本,模拟器不会为 Wi-Fi 提供虚拟硬件。来自 Android 开发者网站:
https://developer.android.com/studio/run/emulator。 html#wi-fi
(了解更多信息 https://developer.android.com/studio/run/ emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi
The emulator does not provide virtual hardware for Wi-Fi if you use API 24 or earlier. From the Android Developers website:
https://developer.android.com/studio/run/emulator.html#wi-fi
(read more at https://developer.android.com/studio/run/emulator.html#about)
https://developer.android.com/studio/run/emulator.html#wi-fi
当使用 API 级别 25 或更高级别的 AVD 时,模拟器会提供模拟的 Wi-Fi 接入点(“AndroidWifi”),Android 会自动连接到它。
来源: https://developer.android.com/studio/run/ emulator.html#wi-fi
When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it.
Source : https://developer.android.com/studio/run/emulator.html#wi-fi
如果你的模拟器没有连接到 wifi 而你使用的是 Mac(我不知道如何在 Windows 上添加 DNS),只需转到
网络->高级-> DNS并添加8.8.8.8和8.8.4.4,然后关闭Android模拟器,打开Android Studio,选择模拟器并单击冷重启,然后您的模拟器将连接到wifi。
If your simulator is not connecting to wifi and you're on a Mac (I don't know how to add DNS on windows) just go to
Network -> advanced -> DNS and add 8.8.8.8 and 8.8.4.4 then close the Android emulator, open Android Studio, select the emulator and click on cold reboot then your emulator will be connected to wifi.