一些常用的ADB命令
阿新 • • 發佈:2021-01-11
開發者官網:Android 除錯橋
設定目標裝置以偵聽埠 5555 上的 TCP/IP 連線。
$ adb tcpip 5555
連線至裝置,通過 IP 地址識別此裝置。
$ adb connect device_ip_address
查詢裝置
$ adb devices
List of devices attached
device_ip_address:5555 device
重置 adb 主機
$ adb kill-server
將命令傳送至特定裝置
$ adb -s serial_number command $ adb -s emulator-5556 install helloWorld.apk
安裝應用
$ adb install path_to_apk
設定埠轉發
$ adb forward tcp:6100 tcp:7100
// 設定傳輸到指定的抽象 UNIX 網域套接字的轉發
$ adb forward tcp:6100 local:logd
從模擬器或裝置複製檔案或目錄(及其子目錄)
$ adb pull remote local
將檔案檔案或目錄(及其子目錄)複製到模擬器或裝置
// local 和 remote 指的是開發計算機(本地)和模擬器/裝置例項(遠端)上目標檔案/目錄的路徑。 $ adb push local remote $ adb push foo.txt /sdcard/foo.txt
發出 shell 命令
$ adb [-d|-e|-s serial_number] shell shell_command
$ adb [-d|-e|-s serial_number] shell
呼叫 Activity Manager (am)
$ adb shell am start -a android.intent.action.VIEW
呼叫軟體包管理器 (pm)
$ adb shell pm uninstall com.example.MyApp
// 輸出所有軟體包
$ adb shell pm list package
進行螢幕截圖
$ adb shell screencap /sdcard/screen.png
錄製視訊
$ adb shell screenrecord /sdcard/demo.mp4
讀取應用的 ART 配置檔案
$ adb shell cmd package dump-profiles package
// 檢索生成的檔案
$ adb pull /data/misc/profman/package.txt
其他 shell 命令
$ adb shell ls /system/bin