Android 模拟器修改hosts文件

2017-09-30  本文已影响553人  9682f4e55d71
============== Cygwin 进入到下面目录执行
$ cd '/d/Android/Android Studio/bin'
$ emulator -writable-system -netdelay none -netspeed full -avd Nexus_5X_API_25
emulator: WARNING: System image is writable
emulator: WARNING: encryption is off
Hax is enabled
Hax ram_size 0x60000000
HAX is working and emulator runs in fast virt mode.
audio: Failed to create voice `goldfish_audio'
qemu-system-i386.exe: warning: opening audio output failed
audio: Failed to create voice `goldfish_audio_in'
qemu-system-i386.exe: warning: opening audio input failed
audio: Failed to create voice `dac'
audio: Failed to create voice `adc'


============= 再在 cmd 执行
D:\Android\Android Studio>adb shell
generic_x86:/ $ su
generic_x86:/ # ls -l /system/etc/hosts
-rw-r--r-- 1 root root 56 2017-02-22 17:07 /system/etc/hosts
127|generic_x86:/ # cat /proc/mounts | grep sys
sysfs /sys sysfs rw,seclabel,relatime 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0
/dev/block/vda /system ext4 ro,seclabel,relatime,data=ordered 0 0    # 注意看这一行,系统的挂在情况

generic_x86:/ # mount -o rw,remount -t yaffs2 /dev/block/vda /system   # 使用读写的方式,重新挂在系统后,即可修改 hosts
generic_x86:/ # ls -l /system/etc/hosts
-rw-r--r-- 1 root root 56 2017-02-22 17:07 /system/etc/hosts
generic_x86:/ # echo "192.168.1.58 koa.example.com" >> /system/etc/hosts
generic_x86:/ # cat /system/etc/hosts
127.0.0.1       localhost
::1             ip6-localhost
192.168.1.58 koa.example.com
generic_x86:/ # echo "192.168.1.58 m.example.com" >> /system/etc/hosts
generic_x86:/ # echo "192.168.1.58 www.example.com" >> /system/etc/hosts

------ adb 报错 error: more than one device/emulator
解决:

$ adb devices
List of devices attached
emulator-5554   device
emulator-5558   offline
C:\Users\dengbeiquan>adb  -s  emulator-5554 shell
generic_x86_64:/ $ su dso
上一篇下一篇

猜你喜欢

热点阅读