2.常用adb命令的使用

使用电脑连接手机,查看手机的唯一编号,如果是模拟器,就是显示地址和端口号:
  adb devices

使用adb安装app应用:
  adb install apk路径和包名
  -r 允许覆盖安装
  -s 将app安装到sd卡中
  -d 允许降级覆盖安装

卸载app应用:
  adb uninstall com.zyxr.home.toulfhome

查看手机中安装的所有应用:
  adb shell pm lisk packages
  -3 显示第三方应用
  -s 显示系统应用
  -d 显示当前不可用的app,disabled
  -e 显示当前可用的app,enabled
  -u 显示的列表中会包含已经卸载的应用

清除应用的数据以及缓存的文件:效果等同于重新安装了一次app
  adb shell pm clear com.pmp.ppmoney

查看包名和当前的页面名:
  adb shell dumpsys window | findstr mCurrentFocus
  adb shell dumpsys activity activities | grep mFocusedActivity
  adb logcat ActivityManager:I *:s

使用adb打开指定的应用:
  adb shell am start -n com.tmall.wireless/.splash.TMSplashActivity

使用adb关闭指定的应用:
  adb shell am force-stop com.tmall.wireless

将手机的文件复制到电脑
  adb pull 手机端的路径和文件名 电脑端的路径

从电脑复制到手机
  adb push 电脑端的路径和文件名 手机端的路径

模拟手机按键的各种方法:
  adb shell input keyevent 3
  3 HOME
  4 返回
  6 挂断电话
  24 增加音量
  25 降低音量
  26 电源
  27 拍照
  82 菜单
  164 静音
  223 系统休眠
  224 点亮屏幕
  231 语音助手

滑动:
  adb shell input swipe x1 y1 x2 y2
  adb shell input swipe 10 100 500 100

输入文本:只能输入在当前聚焦的位置
  adb shell input text hello

日志:
清除日志:
  adb logcat -c
查看日志:
  adb logcat
  verbose   V     --显示的日志内容是最多的  等级是最低的
  debug     D
  Info      I
  warning   W
  error     E
  fatal     F
  silent    S     --什么都不显示  等级是最高的
  adb logcat *:W

查看系统内核的日志:
  adb shell dmesg

查看设备信息:
  adb shell getprop ro.product.model

查看电池的状态:
  adb shell dumpsys battery
  scale  电池的状态
  level  剩余电量

查看屏幕分辨率:px
  adb shell wm size

查看屏幕的密度:dpi
  adb shell wm density

查看显示屏的所有参数:
  adb shell dumpsys window displays

查看android设备的id:
  adb shell settings get secure android_id

查看android系统版本:
  adb shell getprop ro.build.version.release

查看CPU的信息:
  adb shell cat /proc/cpuinfo

保存屏幕截图:
  adb shell screencap -p /data/anr/sc.png
  -p的参数的意思是将图片保存为png的格式

保存屏幕录像:
  adb shell screenrecord /data/anr/sc.mp4

查看手机进程:
  adb shell ps

查看手机的资源占用情况:
  adb shell top

重启手机:
  adb reboot

猜你喜欢

转载自www.cnblogs.com/cmnz/p/9202374.html