android模擬器修改host

我是mac系統,我在這裏記錄一下shell

1、writable-system方式啓動模擬器

1 cd ~/Library/Android/sdk/platform-tools //進入目標文件夾 
2 emulator -list-avds //列出全部模擬器 
3 emulator -avd Nexus_S_API_24_X86 -writable-system //啓動你想要修改的模擬器

2、修改hosts文件

1 adb root //root 運行 
2 adb remount //掛載文件
3 adb pull /system/etc/hosts ~/Desktop/hosts //將hosts文件放在指定文件夾下(本文中放在桌面) 
4 手動在指定文件夾下(本文中放在桌面)打開host文件修改
5 adb push ~/Desktop/hosts /system/etc/hosts //將修改完成的hosts文件放到模擬器中。 
6 adb shell cat /etc/hosts //查看host文件是否修改爲功

參考:https://blog.csdn.net/mq2553299/article/details/68065469.net