如果 Android 模拟器无法上网,测试 adb shell 里 ping 域名解析不出 IP,可以试试用 ./emulator/emulator -avd <name> -dns-server 1.1.1.1 启动。

When starting the emulator at the command line, you can also use the -dns-server <serverList> option to manually specify the addresses of DNS servers to use, where <serverList> is a comma-separated list of server names or IP addresses. You might find this option useful if you encounter DNS resolution problems in the emulated network (for example, an "Unknown Host error" message that appears when using the web browser).

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

标签: Android

添加新评论