(把实践过程中的大坑小坑……都记下来,每天进步一点点)
环境:win10,夜神模拟器v6.6.0.9,adb v1.0.41,gitbash
运行命令:adb shell "uiautomator dump && cat /storage/emulated/legacy/window_dump.xml"
出现报错/bin/sh:xx(命令) not found
常见的原因是权限不够,可以先查看/storage/emulated/legacy的权限情况。
执行adb shell命令,进入上面目录:
$ adb shell
root@shamu:/ # cd /storage
cd /storage
root@shamu:/storage # ll
ll
dr-xr-xr-x root root 2020-07-21 08:56 emulated
lrwxrwxrwx root root 2020-07-21 08:56 sdcard0 -> /storage/emulated/legacy
修改emulated目录权限为777,出现Read-only file system报错:
root@shamu:/storage # chmod 777 emulated
chmod 777 emulated
Unable to chmod emulated: Read-only file system
这个时候我们先回到根目录,执行命令mount -o remount rw /,再重新为emulated设置777的权限:
root@shamu:/ # mount -o remount rw /
mount -o remount rw /
root@shamu:/ # cd /storage
cd /storage
root@shamu:/storage # ll
ll
dr-xr-xr-x root root 2020-07-21 08:56 emulated
lrwxrwxrwx root root 2020-07-21 08:56 sdcard0 -> /storage/emulated/legacy
root@shamu:/storage # chmod 777 emulated
chmod 777 emulated
root@shamu:/storage # ll
ll
drwxrwxrwx root root 2020-07-21 08:56 emulated
lrwxrwxrwx root root 2020-07-21 08:56 sdcard0 -> /storage/emulated/legacy
可以看到emulated已经是rwx的权限了。
这个时候,再重新查看dump文件就没问题了。
P.S.
mount –o remount rw / 这个命令让/路径文件系统为可读写模式,即系统重新挂载一次。