1、ADB命令的安裝:
brew cask install android-platform-tools
2、電腦和手機的連接:
- 打開Android手機的USB調試模式,並連接到MAC電腦
- 使用命令【adb devices】查看已連接的手機,如果找不到,則:
- 使用命令【system_profiler SPUSBDataType】查看手機的VID,並將VID寫入到~/.android/adb_usb.ini文件中,該文件可能需要新建。
- 使用命令【adb kill-server】停止服務,並使用命令【adb start-server】重啟服務
- 再次執行【adb devices】查看已連接的手機。
[參考]: Mac下如何用USB調試Android真機
3、ADB常用命令(不斷增加)
- 查看ADB版本:adb version
- 查看手機設備:adb devices
- 查看設備型號:adb shell getprop ro.product.model
- 查看電池信息:adb shell dumpsys battery
- 查看設備ID:adb shell settings get secure android_id
- 查看設備IMEI:adb shell dumpsys iphonesubinfo
- 查看Android版本:adb shell getprop ro.build.version.release
- 查看手機網絡信息:adb shell ifconfig
- 查看設備日志:adb logcat
- 重啟手機設備:adb reboot
- 安裝一個apk:adb install /path/demo.apk
- 卸載一個apk:adb uninstall <package>
- 查看系統運行進程:adb shell ps
- 查看系統磁盤情況:adb shell ls /path/
- 手機設備截屏:adb shell screencap -p /sdcard/aa.png
- 手機文件下載到電腦:adb pull /sdcard/aa.png ./
- 電腦文件上傳到手機:adb push aa.png /data/local/
- 手機設備錄像:adb shell screenrecord /sdcard/ab.mp4
- 手機屏幕分辨率:adb shell wm size
- 手機屏幕密度:adb shell wm density
- 手機屏幕點擊:adb shell input tap xvalue yvalue
- 手機屏幕滑動:adb shell input swipe 1000 1500 200 200
- 手機屏幕帶時間滑動:adb shell input swipe 1000 1500 0 0 1000
- 手機文本輸入:adb shell input text xxxxx
- 手機鍵盤事件:adb shell input keyevent xx
- 連接多個手機設備時,指定手機設備:adb -s serialNumber <command>
4、ADB無線連接
- 保證手機和電腦處在同一個無線網絡內
- 在USB連接的基礎上,執行命令【adb tcpip 5555】
- 斷開USB連接,執行命令【adb connect 192.168.x.x:5555】
- 此時執行命令【adb devices】即可查看到連接的手機設備信息
5、 Monkey
adb shell monkey -p com.wifi.reader --throttle 1000 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v –s 1540475754297 1000 e:\monkey.log
adb shell monkey -p com.vivi.xxx.app --ignore-crashes --ignore-timeouts --ignore-security-exceptions --throttle 200 -v -s 125461 500000 > global1.log
6、 adb查看奔潰日志
- adb logcat -c 可以將之前的日志信息清空,重新開始輸出日志信息.
- -c:清空所有到日志緩存信息
- -b:加載一個日志緩沖區,
- -t:輸出最近到幾行日志,輸出完退出,不阻塞; adb logcat -t 5 (輸出最近的5行日志)
- -g:查看日志緩沖區信息;
-
使用-f,-d,-s,-v,-b格式:
-f ——> 輸出日志到到sd卡
-d ——> 一次性輸出日志到屏幕上,自動終止返回
-s ——> 設置tag,默認的過濾級別為Silent
-v ——> 設置日志消息的輸出格式 adb logcat -v threadtime ——> 打印日期,時間,優先級/標記,PID和TID
-b ——> 查看日志消息的緩沖區
adb logcat -b crash //查看crash的信息 adb logcat -b main //查看主要的日志緩沖區 adb logcat -b events //查看包含事件相關消息的緩沖區 adb logcat -b system // 查看system相關的信息 adb logcat -b radio // 查看包含無線裝置/電話相關消息的緩沖區
This adb server's $ADB_VENDOR_KEYS is not set
- Delete the folder "C:/Users/$Name/.android" ~/.android
- Restart the adb server (
adb kill-server; adb start-server) - Next time you use adb to access the device, a popup will appear on device asking to allow to connect to adb server
https://www.cnblogs.com/helloTerry1987/p/11069148.html
