在我們平時的開發過程,會時常碰到bug,除了用Android studio自帶的調試和過濾log的方式外,用adb也可以做到抓取log分析,當然adb的作用除了可以抓取log外,還有很多其他有用的作用.常用的比如有:
1.在終端動態抓取log:
adb logcat
2.查看當前鏈接設備:
adb devices
//比如現在連接的是模擬器
List of devices attached
emulator-5554 device
3.查找某一個app的安裝路徑和清除app數據:
adb shell pm path <包名>
adb shell pm clear <包名>
4.查看設備屏幕相關參數:
adb shell wm density //獲取屏幕密度
adb shell wm size //獲取屏幕像素值
5.殺死和重啟adb服務:
adb kill-server //殺死adb服務
adb restart-server//重啟adb服務
6.重啟手機
adb reboot
7.進入手機:
adb shell
8.在開發過程中有可能要模擬一下組件的交互過程:
adb shell am start [options] <INTENT>//開啟activity
adb shell am startservice [options] <INTENT>//開啟service
adb shell am broadcast [options] <INTENT>//開啟廣播
當然還有很多有用的adb命令,可以按照自己的需要去熟悉和學習,在這提供一個adb命令大全,有需要的時候可以到這上面查查.
adb命令大全
gazanie-2714025_960_720.jpg