用模拟器调试程序,并且当服务器没有正式发布的时候就需要配置host。。。
没有可用的hosts文件时:
添加换行符另起一行: 使用 echo -e \\n >> /system/etc/hosts 为hosts文件加入换行符。
将目标地址添加进hosts文件: 首先键入 adb shell 命令,然后echo 192.168.0.246 www.aaa.com>>/system/etc/hosts。。
有可用的hosts文件时:
adb root
adb remount
adb push d:/hosts /system/etc/hosts
adb shell
cat /system/etc/hosts
adb kill-server
adb start-server
adb remount
有两个需要注意的地方:
1,hosts文件不能用Windows系统编译,因为Windows和android所使用的linux系统的换行符不一样。
2,模拟器修改hosts后重启将会还原。。。。