ADB:運行adb shell uiautomator dump並查看dump文件,由於權限問題報錯的解決辦法


(把實踐過程中的大坑小坑……都記下來,每天進步一點點)

環境: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 / 這個命令讓/路徑文件系統為可讀寫模式,即系統重新掛載一次。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM