自己总结,方便自己使用
adb devices
adb get-state
adb version
adb install xxx/xxx.apk
adb uninstall com.app.xxx(应用包名)
adb start-server
adb kill-server
从安卓设备复制到电脑:
adb pull sdcard/xxx.txt d:\
从电脑复制到安卓设备:
adb push d:\xxx.txt sdcard/
重启
adb reboot
重启进入recovery模式
adb reboot recovery
重启进入fastboot模式
adb reboot bootloader
MTK平台:
adb reboot fastboot
RK平台:
adb reboot loader
a.电脑和安卓设备处于同一局域网下
b.安卓设备进入开发者模式打开WiFi调试
c.电脑端执行adb connect 192.168.1.102(安卓设备IP)
adb logcat > d:\xxx.txt
adb root
adb remount
adb shell pm list package
adb shell pm list package -s
adb shell pm list package -3
adb shell pm list package -f
adb shell pm dump com.tencent.mobileqq
adb shell pm list package -f | findstr gps
adb shell pm install sdcard/xxx.apk
adb shell pm uninstall com.xxx.xxx.apk ---与adb uninstall相同
adb shell pm clear com.app.xxx
[0/auto]:默认为自动
[1/internal]:默认为安装在手机内部
[2/external]:默认安装在外部存储
获取:
adb shell pm get-install-location
设置:
adb shell pm set-install-location 0
adb shell pm list permissions -f
adb shell pm list users -f
adb shell am start -n com.mediatek.mtklogger/com.mediatek.mtklogger.MainActivity
adb shell am start -n com.android.camera/.Camera Starting: Intent { cmp=com.android.camera/.Camera }
adb shell am start -a android.intent.action.VIEW -d http://testerhome.com
adb shell am start -a android.intent.action.CALL -d tel:10086
adb shell am monitor
adb shell am instrument
adb shell am force-stop com.example.filetorw
adb shell am startservice -n {包(package)名}/{包名}.{服务(service)名称}
例:
adb shell am startservice -n com.example.servicetest/com.example.servicetest.MyService
发送一个网络变化的广播
adb shell am broadcast -a android.net.conn.CONNECTIVITY_CHANGE
adb shell am start -n com.android.launcher3/com.android.launcher3.Launcher
adb shell am start -n com.android.settings/.Settings
adb shell input text test123456
按下home键
adb shell input keyevent KEYCODE_HOME
按下back键
adb shell input keyevent BACK
点亮/熄灭手机屏幕,说明:keyevent 后面数字是键值,26代表手机电源键
adb shell input keyevent 26
adb shell input tap 500 500
adb shell input swipe 900 500 100 500
adb shell screencap -p /sdcard/screen.png
adb shell screenrecord sdcard/record.mp4
adb shell uiautomator dump
adb shell ime list -s
输出结果:
com.baidu.input_mi/.ImeService
adb shell ime set com.baidu.input_mi/.ImeService
adb shell wm size
一定要先执行adb shell,在执行后面的monkey命令,否则无法再sdcard中创建日志文件
adb shell
monkey -s 1000 --pct-syskeys 0 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --pct-trackball 0 --pct-nav 0 --pct-majornav 0 --pct-anyevent 0 -v -v -v --throttle 500 1800000000 1>/sdcard/Monkey1.txt 2>/sdcard/Monkey2.txt
adb shell
monkey -p com.android.camera2 -s 1000 --pct-syskeys 0 --ignore-crashes --ignore-timeouts --ignore-security-exceptions -v -v -v --throttle 1000 1000000 1>/sdcard/CameraMonkey1.txt 2>/sdcard/CameraMonkey2.txt
adb shell getprop
adb shell cat /proc/cpuinfo
导出设备序列号
adb get-serialno > aaa.txt
导出MAC地址
adb shell cat /sys/class/net/wlan0/address > aaa.txt
导出设备型号
adb shell getprop ro.product.model > aaa.txt
导出系统版本
adb shell getprop ro.build.version.release> aaa.txt
导出屏幕分辨率
adb shell wm size > aaa.txt
导出屏幕密度
adb shell wm density > aaa.txt
导出CPU信息
adb shell cat /proc/cpuinfo > aaa.txt
1是打开画线 ,0是关闭
adb shell settings put system pointer_location 1
1是打开,0是关闭
adb shell settings put system show_touches 1
以上就是今天要讲的内容,本文仅仅简单介绍了adb常用的一些命令,而adb还有大量不常用的命令,有需要可自行研究