安卓模拟器修改host

1,065 阅读1分钟

实现效果

查看设备

emulator -list-avds

output:
Nexus_5X_API_24
Pixel_2_API_26

启动设备

emulator -avd Pixel_2_API_26 -writable-system

output:
emulator -avd Pixel_2_API_26 -writable-system
emulator: WARNING: System image is writable
emulator: INFO: boot completed

执行权限

adb disable-verity # 如果权限不行再执行这个
➜   adb root root
restarting adbd as root
➜   adb remount
remount succeeded

修改host

# 将hosts文件放在指定文件夹下(本文中放在桌面)
adb pull /system/etc/hosts ~/Desktop/hosts 


➜   adb push ~/Desktop/hosts /system/etc/hosts
/Users/gaopo/Desktop/hosts: 1 file ...hed. 0.0 MB/s (118 bytes in 0.008s)

~/Desktop/hosts 文件内容