Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.
通用
adb -s <device name> <command>
|
devices
install
adb install <target apk name>.apk
|
adb install -r <target apk name>.apk
|
remount
- 在CMD下直接刪除和上傳檔案到機器
logcat
- 查看含有特定字串的log
adb logcat <target string>:V *:S
|
shell
adb shell dumpsys notification
|
adb shell service call notification 1
|
adb shell input swipe x1 y1 x2 y2
|
adb shell input keyevent <keycode>
|
Reference
adb shell dumpsys meminfo <package name>
|
adb shell dumpsys activity activities | sed -En -e '/Stack #/p' -e '/Running activities/,/Run #0/p'
|
adb shell am start -a android.intent.action.VIEW -d "<link>" (<package>)
|
In shell mode
Run-as
// in shell run-as <package-name>
|
Combination
adb shell ps | grep <package>
|
// Emulator需要用api google cat /proc/<pid>/maps
|
需要使用沒有Google play的emulator
adb shell run-as "<package>" ls -al /proc/<pid>/fd | wc -l
|
adb shell ps -T | grep "<pid>" | wc -l
|
- 查看name程序的memory使用量,並以RSS欄位為準
adb shell ps | grep "name"
|
Error handle
- Eclipse error: ADB server didn’t ACK, * failed to start daemon *
通常直接刪除tfadb.exe這程序然後直接重啟adb server可解除,如不行則依照以下步驟 -- //這是因為adb使用的port 5037被佔用了,找出誰占用 netstat -aon|findstr "5037" TCP 127.0.0.1:3477 127.0.0.1:5037 XXXXXX 5263 TCP 127.0.0.1:3478 127.0.0.1:5037 XXXXXX 5263 -- //依照PID反查程序名稱 tasklist | findstr "5263" xxx.exe 5263 Console 0 x.xxxk -- //刪除程序 taskkill /f /t /imxx.exe -- //重開adb,隨便執行一adb指令 adb devices
|
Reference