Android 修改Hosts

前言:

项目中有需要对system/etc/hosts进行修改。

环境
系统类型 userdebug
系统版本 9.0
方案商 MTK

问题:

system/etc/hosts仅root用户可以修改

步骤:

1,以root用户进入shell

adb root

adbd is already running as root

2,重新挂载设备

adb remount

remount of the / superblock failed: Permission denied

2,汗,提示没有权限,需要关闭验证,原因是9.0开启了avb2.0,看这里

adb disable-verity

Device is locked. Please unlock the device first

3,哎,提示要先解锁设备,好吧,重启进入bootloader后,进行解锁。

adb reboot bootloader

fastboot flashing unlock

(bootloader) Start unlock flow

OKAY [ 8.215s]
Finished. Total time: 8.215s

4,设备解锁成功,再次确认下呢

fastboot getvar unlocked

unlocked: yes
Finished. Total time: 0.007s

5,现在还在fastboot模式,正常重启下

fastboot reboot

Rebooting OKAY [ 0.007s]
Finished. Total time: 0.058s

6,重启开机了,再来一次root角色进入

adb root

restarting adbd as root

7,恍如昨日,这次关闭验证成功!!!

adb disable-verity

Successfully disabled verity
Now reboot your device for settings to take effect

8,提示还要重启,麻烦。

adb reboot

9,还记得root角色进入吗?哭脸

adb root

restarting adbd as root

10,我觉得是时候结束了!!!

adb remount

remount succeeded

最后

愉快的修改hosts,缺少vim?? 最好adb pull出来,在pc上用编辑器修改完成后,push回去。

箴言(血泪史,我用红字显得警醒)

在windows下编辑的hosts,包含windows格式的回车换行符,一定要在linux环境下编辑,或者自行找方法替换。

windows:\r\n

linux:\n

猜你喜欢

转载自blog.csdn.net/lucky_tom/article/details/116263636