由于后端域名对应的IP地址变更,需要测试移动端是否会受到影响。可以通过修改模拟器的hosts文件实现该测试。
- 先安装PC的adb环境,并配置好环境变量;
- 雷电模拟器打开可写入,默认是只读。(设置-磁盘-系统盘设置)。
- 雷电模拟器开启ROOT权限。(设置-其他-打开 ROOT 权限)。
- 找到雷电模拟器安装目录,
shift+鼠标右键打开CMD或是PowerShell都可以,打开文件夹写入权限:
adb root
adb remount
5. 执行adb devices找到设备名称,再执行adb -s emulator-5554 pull /system/etc/hosts把hosts文件导出来。
6. 上传新的hosts文件
adb -s emulator-5554 push hosts /system/etc/hosts(方法1 简写路径)adb -s emulator-5554 push C:\leidian\hosts /system/etc/hosts(方法2 也可以用完整路径)
完整流程:
🍎完整代码
adb root
adb remount
adb devices
adb -s emulator-5554 pull /system/etc/hosts
adb -s emulator-5554 push hosts /system/etc/hosts