模拟器访问PC机WEB服务器方法

模拟器默认访问PC机的IP地址为: http://10.0.2.2/

如果要用域名访问,可以用APACHE做代理处理:ProxyPass / http://www.localhost.com/

或者修改模拟器的HOST做下域名解析处理,例如在HOST加入:

10.0.2.2 www.localhost.com

android模拟器修改 andorid上的 hosts文件,具体步骤如下

1、获得root权限:adb root

2、设置/system为可读写:adb remount

3、将hosts文件复制到PC:adb pull /system/etc/hosts <PC机上文件名>

4、修改PC机上文件

5、将PC机上文件复制到手机:adb push <PC机上文件名> /system/etc/hosts

但在第五步时,有的人会报  out of memory的错误

这是因为直接用命令行启动,而没加一个参数造成的,所以用下面这个命令来启动就行了

$emulator –avd youravdname –partition-size 128

 

你可能感兴趣的:(模拟器访问PC机WEB服务器方法)