ADB命令

ADB常用命令

一、adb下载地址
Windows版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
Mac版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
Linux版本:https://dl.google.com/android/repository/platform-tools-latest-linux.zip

2.配置环境变量

1、键盘按键:win + r 2、打开“系统属性”窗口 3、“高级”→“环境变量”→“系统变量” 4、找到“Path”双击,新建,复制adb路径进去,点击“确定”按钮,添加成功

3.验证是否安装成功

1、键盘按键:win + r 2、输入cmd,回车 3、输入adb或者adb --version(注意是两个“-”)

通过数据线连接PC端与移动端

//通过IP地址连接到设备

adb connect IP :5555

adb connect IP :62001(链接模拟器,不同的模拟器端口号不同)

//当出现连不上时先:

1、先通过USB线连上设备

2、adb tcpip [port]

//服务启动/停止

启动服务:adb start-server

停止服务:adb kill -server

//安装包

adb install d:/a.apk

//覆盖安装

adb install -r d:/a.apk(可以直接把安装包拖动到命令窗口)

//卸载包:

adb uninstall com.au.ukds.teacher

查看目录结构:adb shell ls

查看系统当前日期:adb shell date

查看系统CPU使用情况:adb shell cat/proc/cpuinfo

查看系统内存使用情况:adb shell cat/proc/meminfo

pm:包管理

am:页面管理

显示所有应用:adb shell pm list packages

显示系统自带应用:adb shell pm list packages -s

显示第三方应用:adb shell pm list packages -3

显示系统所有功能:adb shell pm list features

显示给定package的APK的路径:adb shell pm path package

//退出adb shell exit

清理缓存数据  adb shell pm clear <包名>

//获取设备当前页面:(先打开页面,再执行命令)

adb shell "dumpsys window | grep mCurrentFocus"

adb shell dumpsys window windows | findstr mFocusedApp

获取启动页面的activity(先执行命令,再打开页面)

mac:adb logcat ActivityManager:I | grep "cmp"

win: adb logcat ActivityManager:I | findstr "cmp"

启动页面 adb shell am start -n <包名>/<activity名>

//从设备复制文件或者目录:adb pull <设备路径> <本地路径>

//将文件或者目录复制到设备:adb push <本地路径> <设备路径>local remote

//截图 adb shell screencap -p /sdcard/01.png

//将截屏的图片下载到桌面,示例:adb pull /sdcard/01.png C:\Users\thinkpad\Desktop

查看日志常用参数

adb logcat    打印默认日志数据

adb logcat -v time   打印时间

adb logcat -v color   使用不同的颜色来显示每个优先级

adb logcat  -f <filename>   将日志输出到文件

adb logcat > log.log   保存日志到PC上

adb logcat -c   清理已存在的日志

根据条件过滤日志

adb logcat -v time "*:w"   打印Warning及以上级别的日志

adb logcat ActivityManager:D '*:S'  过滤tag 为ActivityManager,level为debug及以上级别的日志

//过滤,只抓取测试包的日志

adb logcat | grep "com.au.ukds.teacher" > C:/1.txt

adb logcat | findstr "com.au.ukds.teacher" > C:/1.txt

//通过adb shell命令查看当前与用户交互的activity

adb shell dumpsys activity | grep -i run

adb shell dumpsys activity | grep "mFoc"

性能参数

查看当前系统CPU使用情况:adb shell dumpsys cpuinfo

查看当前系统的内存:adb shell dumpsys meminfo

查看某个应用的内存:adb shell dumpsys meminfo <包名>

top命令

adb shell top

mac/linux:adb shell top | grep "包名"     查看某个包的一些性能指标

windows:adb shell top | findstr "包名"    查看某个包的一些性能指标

adb shell top -d 1 | grep "包名"

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值