修改Android模拟器中的文件
本地开发机运行着server向跑在模拟器中的app提供rest api服务。
1)模拟器中的127.0.0.1是指模拟器自己本机。
2)模拟器中使用10.0.2.2来访问开发机。
3)如果在本地tomcat启用了虚拟主机,可以修改模拟器中的/etc/hosts来指向域名。
// 列出安装的模拟器
emulator -list-avds
// 以可写模式启动模拟器
emulator -avd Your_Emulator_Name -writable-system
adb root
adb remount
// 把模拟器上的文件pull到本地
adb pull /etc/hosts newHosts
// 添加 "10.0.2.2 your_domain"
vi newHosts
adb push newHosts /etc/hosts
// 进入模拟器的shell
adb shell