【汇总】android adb 命令功能大全

发布时间 2023-12-27 15:11:05作者: 悟透

前言全局说明

adb 命令是 Android 官方提供,调试 Android 系统的工具。


一、基础命令

adb reboot #重启
adb help #查看ADB 帮助

二、查看设备

adb devices #查看连接设备

三、连接设备

adb [-d|-e|-s <serialNumber>] <command>
连接指定设备

参数:
-d 指定当前唯一通过USB 连接的Android 设备为命令目标
-e 指定当前唯一运行的模拟器为命令目标
-s <serialNumber> 指定相应serialNumber 号的设备/模拟器为命令目标
command 为所需对设备执行的命令

示例:

adb -s cf27456f shell # 指定连接设备使用命令

四、安装、卸载APP应用

1.安装应用

adb install test.apk # 安装应用
adb install -r demo.apk #安装apk 到sd 卡:

2.卸载应用

adb uninstall cn.com.test.mobile #卸载应用,需要指定包
adb uninstall -k cn.com.test.mobile #卸载app 但保留数据和缓存文件

五、adb shell

1.adb shell am

adb shell am start -ncn.com.test.mobile/.ui.SplashActivity #启动应用
adb shell am force-stop cn.com.test.mobile #强制停止应用

2.adb shell pm

adb shell pm list packages #列出手机装的所有app 的包名
adb shell pm list packages -3 #列出除了系统应用的第三方应用包名
adb shell pm clear cn.com.test.mobile #清除应用数据与缓存

3.adb shell dumpsys

adb shell dumpsys package #包信息Package Information
adb shell dumpsys meminfo #内存使用情况Memory Usage

4.adb shell getprop

adb shell getprop ro.build.version.release #查看Android 系统版本

5.adb shell top

adb shell top -s 10 #查看占用内存前10 的app

六、上传、下载文件

adb push <local> <remote> #从本地复制文件到设备
adb pull <remote> <local> #从设备复制文件到本地

七、log & bug log

adb logcat #查看日志
adb logcat -c #清除log 缓存
adb get-serialno #获取序列号
adb bugreport #查看bug 报告


免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。




参考、来源:
https://blog.csdn.net/y281252548/article/details/130619040