启动Android模拟器后,使用其中的浏览器访问外网,发现无法访问。
1. 检查Android模拟器网络环境
首先cmd 进入C:\Program Files (x86)\Android\android-sdk\platform-tools。
然后运行adb shell,进入shell模式。
运行getprop,获取模拟器环境信息,输出如下:
[ARGH]: [ARGH]
[dalvik.vm.heapsize]: [32m]
[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]
[dev.bootcomplete]: [1]
[gsm.current.phone-type]: [1]
[gsm.defaultpdpcontext.active]: [true]
[gsm.network.type]: [UMTS]
[gsm.operator.alpha]: [Android]
[gsm.operator.iso-country]: [us]
[gsm.operator.isroaming]: [false]
[gsm.operator.numeric]: [310260]
[gsm.sim.operator.alpha]: [Android]
[gsm.sim.operator.iso-country]: [us]
[gsm.sim.operator.numeric]: [310260]
[gsm.sim.state]: [READY]
[gsm.version.ril-impl]: [android reference-ril 1.0]
[init.svc.adbd]: [running]
[init.svc.bootanim]: [stopped]
[init.svc.console]: [running]
[init.svc.debuggerd]: [running]
[init.svc.drm]: [running]
[init.svc.goldfish-logcat]: [stopped]
[init.svc.goldfish-setup]: [stopped]
[init.svc.installd]: [running]
[init.svc.keystore]: [running]
[init.svc.media]: [running]
[init.svc.netd]: [running]
[init.svc.qemu-props]: [stopped]
[init.svc.qemud]: [running]
[init.svc.ril-daemon]: [running]
[init.svc.servicemanager]: [running]
[init.svc.surfaceflinger]: [running]
[init.svc.ueventd]: [running]
[init.svc.vold]: [running]
[init.svc.zygote]: [running]
[net.bt.name]: [Android]
[net.change]: [net.dnschange]
[net.dns1]: [10.0.2.3]
[net.dns2]: [10.0.2.4]
[net.dns3]: [10.0.2.5]
[net.dnschange]: [1]
[net.eth0.dns1]: [10.0.2.3]
[net.eth0.dns2]: [10.0.2.4]
[net.eth0.dns3]: [10.0.2.5]
[net.eth0.gw]: [10.0.2.2]
[net.gprs.local-ip]: [10.0.2.15]
[net.hostname]: [android-8865761b8417d9a6]
[net.qtaguid_enabled]: [0]
[net.tcp.buffersize.default]: [4096,87380,110208,4096,16384,110208]
[net.tcp.buffersize.edge]: [4093,26280,35040,4096,16384,35040]
[net.tcp.buffersize.evdo]: [4094,87380,262144,4096,16384,262144]
[net.tcp.buffersize.gprs]: [4092,8760,11680,4096,8760,11680]
[net.tcp.buffersize.hsdpa]: [4094,87380,262144,4096,16384,262144]
[net.tcp.buffersize.hspa]: [4094,87380,262144,4096,16384,262144]
[net.tcp.buffersize.hspap]: [4094,87380,1220608,4096,16384,1220608]
[net.tcp.buffersize.hsupa]: [4094,87380,262144,4096,16384,262144]
[net.tcp.buffersize.lte]: [524288,1048576,2097152,262144,524288,1048576]
[net.tcp.buffersize.umts]: [4094,87380,110208,4096,16384,110208]
[net.tcp.buffersize.wifi]: [524288,1048576,2097152,262144,524288,1048576]
[persist.sys.country]: [US]
[persist.sys.language]: [en]
[persist.sys.localevar]: []
[persist.sys.profiler_ms]: [0]
[persist.sys.timezone]: [GMT]
[persist.sys.usb.config]: [adb]
[qemu.hw.mainkeys]: [1]
[qemu.sf.fake_camera]: [back]
[qemu.sf.lcd_density]: [240]
[rild.libargs]: [-d /dev/ttyS0]
[rild.libpath]: [/system/lib/libreference-ril.so]
[ro.allow.mock.location]: [1]
[ro.baseband]: [unknown]
[ro.board.platform]: []
[ro.bootloader]: [unknown]
[ro.bootmode]: [unknown]
[ro.build.characteristics]: [default]
[ro.build.date.utc]: [1360768853]
[ro.build.date]: [Wed Feb 13 15:20:53 UTC 2013]
[ro.build.description]: [sdk-eng 4.2.2 JB_MR1.1 576024 test-keys]
[ro.build.display.id]: [sdk-eng 4.2.2 JB_MR1.1 576024 test-keys]
[ro.build.fingerprint]: [generic/sdk/generic:4.2.2/JB_MR1.1/576024:eng/test-keys]
[ro.build.host]: [wpee3.hot.corp.google.com]
[ro.build.id]: [JB_MR1.1]
[ro.build.product]: [generic]
[ro.build.tags]: [test-keys]
[ro.build.type]: [eng]
[ro.build.user]: [android-build]
[ro.build.version.codename]: [REL]
[ro.build.version.incremental]: [576024]
[ro.build.version.release]: [4.2.2]
[ro.build.version.sdk]: [17]
[ro.com.google.locationfeatures]: [1]
[ro.config.alarm_alert]: [Alarm_Classic.ogg]
[ro.config.nocheckin]: [yes]
[ro.config.notification_sound]: [OnTheHunt.ogg]
[ro.debuggable]: [1]
[ro.factorytest]: [0]
[ro.hardware]: [goldfish]
[ro.kernel.android.checkjni]: [1]
[ro.kernel.android.qemud]: [ttyS1]
[ro.kernel.console]: [ttyS0]
[ro.kernel.ndns]: [3]
[ro.kernel.qemu.gles]: [0]
[ro.kernel.qemu]: [1]
[ro.product.board]: []
[ro.product.brand]: [generic]
[ro.product.cpu.abi2]: [armeabi]
[ro.product.cpu.abi]: [armeabi-v7a]
[ro.product.device]: [generic]
[ro.product.locale.language]: [en]
[ro.product.locale.region]: [US]
[ro.product.manufacturer]: [unknown]
[ro.product.model]: [sdk]
[ro.product.name]: [sdk]
[ro.radio.use-ppp]: [no]
[ro.revision]: [0]
[ro.runtime.firstboot]: [1368492227188]
[ro.secure]: [0]
[ro.serialno]: []
[ro.setupwizard.mode]: [EMULATOR]
[ro.wifi.channels]: []
[service.bootanim.exit]: [1]
[status.battery.level]: [5]
[status.battery.level_raw]: [50]
[status.battery.level_scale]: [9]
[status.battery.state]: [Slow]
[sys.boot_completed]: [1]
[sys.usb.config]: [adb]
[sys.usb.state]: [adb]
[system_init.startsurfaceflinger]: [0]
[xmpp.auto-presence]: [true]
发现模拟器的IP地址为[net.gprs.local-ip]: [10.0.2.15],网关为[net.eth0.gw]: [10.0.2.2],DNS有三个地址如下:
[net.eth0.dns1]: [10.0.2.3]
[net.eth0.dns2]: [10.0.2.4]
[net.eth0.dns3]: [10.0.2.5]
2. 检查电脑的网络环境
在命令窗口下,运行ipconfig /all,输出如下:
连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : Intel(R) Centrino(R) Advanced-N 6205
物理地址. . . . . . . . . . . . . : 84-3A-4B-B8-00-80
DHCP 已启用 . . . . . . . . . . . : 是
自动配置已启用. . . . . . . . . . : 是
IPv4 地址 . . . . . . . . . . . . : 192.168.0.101(首选)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
获得租约的时间 . . . . . . . . . : 2013年5月14日 8:18:08
租约过期的时间 . . . . . . . . . : 2013年5月15日 8:18:07
默认网关. . . . . . . . . . . . . : 192.168.0.1
DHCP 服务器 . . . . . . . . . . . : 192.168.0.1
DNS 服务器 . . . . . . . . . . . : 192.168.0.1
TCPIP 上的 NetBIOS . . . . . . . : 已启用
发现DNS 服务器是192.168.0.1。
在adb shell模式下,运行
setprop net.dns1 192.168.0.1。
4. 重新启动Android模拟器,使用浏览器访问外网,这次成功了。
4. 重新启动Android模拟器,使用浏览器访问外网,这次成功了。
参考文献:
1. http://my.oschina.net/oncereply/blog/16821
2. http://blog.sina.com.cn/s/blog_82f2fc280100ywrd.html
3. http://www.eoeandroid.com/thread-61676-1-1.html
1. http://my.oschina.net/oncereply/blog/16821
2. http://blog.sina.com.cn/s/blog_82f2fc280100ywrd.html
3. http://www.eoeandroid.com/thread-61676-1-1.html
没有评论:
发表评论