ADB | |
adb Android Debug Bridge | ...SDK\tools |
adb devices | 獲取設備列表及設備狀態 |
adb get-state | 獲取設備的狀態 |
adb start-server | 啓動 adb 服務 |
adb kill-server | 結束 adb 服務 |
adb logcat | 打印 Android 的系統日誌 |
adb bugreport | 打印dumpsys、dumpstate、logcat的輸出,也是用於分析錯誤 |
adb install | 安裝應用,覆蓋安裝是使用 -r 選項 |
adb uninstall | 卸載應用,後面跟的參數是應用的包名,請區別於 apk 文件名 |
adb pull | 將 Android 設備上的文件或者文件夾複製到本地 |
adb push | 推送本地文件至 Android 設備 |
adb root , adb remount | 只針對類似小米開發版的手機有用,可以直接已這兩個命令獲取 root 權限,並掛載系統文件系統爲可讀寫狀態 |
adb reboot | 重啓 Android 設備 |
adb forward | 將 宿主機上的某個端口重定向到設備的某個端口 |
adb connect | 遠程連接 Android 設備 |
adb shell pm list package | 列出所有的應用的包名(不知道怎麼找應用的包名的同學看這裏) |
adb shell pm list package -s | -s:列出系統應用 |
adb shell pm list package -3 | -3:列出第三方應用 |
adb shell pm list package -f | -f:列出應用包名及對應的apk名及存放位置 |
adb shell pm list package -i | -i:列出應用包名及其安裝來源,結果顯示例子: |
pm install | 安裝應用 |
pm uninstall | 卸載應用 |
pm clear | 清除應用數據 |
pm set-install-location | 設置應用安裝位置, |
pm get-install-location | 獲取應用安裝位置 |
adb shell am start -n com.android.camera/.Camera | 啓動相機 |
adb shell am start -S com.android.camera/.Camera | 先停止目標應用,再啓動 |
adb shell am start -W com.android.camera/.Camera | 等待應用完成啓動 |
adb shell am start -a android.intent.action.VIEW -d |
啓動默認瀏覽器打開一個網頁 |
adb shell am start -a android.intent.action.CALL -d tel: | 啓動撥號器撥打 |
adb shell am monitor | |
adb shell input text test123456 | 前提先將鍵盤設置爲英文鍵盤 |
adb shell input keyevent KEYCODE_HOME | 模擬按下 Home 鍵 ,KEYCODE_HOME 替換爲 3 |
adb shell input tap 500 500 | 點擊屏幕上座標爲 500 500 的位置 |
adb shell input swipe 900 500 100 500 | 從右往左滑動屏幕 |
adb shell input swipe 500 500 501 501 2000 | 其實就是在小的距離內,在較長的持續時間內進行滑動,最後表現出來的結果就是長按動作 |
adb shell screencap -p /sdcard/screen.png | 截屏,保存至 sdcard 目錄 |
adb shell screenrecord sdcard/record.mp4 | 執行命令後操作手機,ctrl + c 結束錄製,錄製結果保存至 sdcard |
adb shell uiautomator dump | 不加 [file] 選項時,默認存放在 sdcard 下 |
adb shell ime list -s | 列出設備上的輸入法 |
adb shell ime set com.baidu.input_mi/.ImeService | 選擇輸入法 |
adb shell wm size | 獲取設備分辨率 |
adb shell log -p d -t xuxu "test adb shell log" | -p:優先級,-t:tag,標籤,後面加上 message |
adb shell getprop ro.build.version.sdk | 獲取設備的 sdk 版本 |
adb shell monkey -p com.android.settings 5000 > d:\monkey.log | 場景1、在 PC 端執行 monkey 命令,將信息保存至 D 盤 monkey.log,會這麼寫: |
adb shell monkey -p com.android.settings 5000 > sdcard/monkey.log | 場景2、在 PC 端執行 monkey 命令,將信息保存至手機的 Sdcard,可能會這麼寫: |
adb shell "monkey -p com.android.settings 5000 > sdcard/monkey.log" |