[英]How to config Android emulator to connect to internet
I've been struggling with how to config my Android emulator to connect to the Internet, and of course I tried a lot of solutions such as disable the LAN card
or add dns
server, http proxy
in eclipse, etc... 我一直在努力配置Android模拟器以连接到Internet,当然,我尝试了很多解决方案,例如禁用
LAN card
或添加dns
服务器,eclipse中的http proxy
等。
Unfortunately, those solutions seem to work very well for lots of people but not for me. 不幸的是,这些解决方案对于很多人来说似乎效果很好,但对我而言却不是。
Finally I found the right solution which is easy to understand, easy to do and works well. 最终,我找到了易于理解,易于执行且效果良好的正确解决方案。
Reason: The reason that your PC can connect to internet but your emulator can't is that emulator's default DNS server is [10.0.2.3] which is different from the real one you are currently using. 原因:您的PC可以连接到Internet但仿真器无法连接的原因是,该仿真器的默认DNS服务器为[10.0.2.3],与当前使用的真实DNS服务器不同。
Steps: 1. 'CMD->ipconfig /all' to get real DNS server eg 192.168.1.1 2. 'CMD->adb shell->getprop' to get emulator's DNS info as following [net.dns1]:[10.0.2.3] 2. 'CMD->adb shell->setprop net.dns1 192.168.1.1' to set DNS server 步骤:1.'CMD-> ipconfig / all'获得真实的DNS服务器,例如192.168.1.1 2.'CMD-> adb shell-> getprop'获得仿真器的DNS信息,如下[net.dns1]:[10.0.2.3] ] 2.'CMD-> adb shell-> setprop net.dns1 192.168.1.1'设置DNS服务器
note. 注意。 if adb shell is not recognized as a valid command, try set ANDROID_HOME and path
如果adb shell无法识别为有效命令,请尝试设置ANDROID_HOME和path
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.