adb 常用命令
前言
adb,全称是 Android Debug Bridge,广泛用于 Android 开发者的调试中。
复制代码
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
//列出设备,返回设备号和设备状态
adb install xxx.apk //安装程序
adb install -r xxx.apk //覆盖安装
adb -s abcdefg install xxx.apk //安装程序到设备号为adbcdefg的设备上
adb uninstall com.test.app //使用包名卸载程序
adb pull /storage/emulated/0/xxx.apk //复制sd卡下文件到当前目录
adb push xxx.apk /storage/emulated/0/ //复制当前目录文件到存储卡目录
adb shell //进入终端后,以下操作即可省略 'adb shell'
adb shell pm clear com.test.app //清空程序数据
adb shell pm list packages //查看app名称
adb shell input text "insert%syour%stext%shere" //输入文字
adb shell input tap 500 1450 //模拟点击坐标(500, 1450)
adb shell input swipe 100 500 100 1450 100 //模拟滑动,从(100, 500)至(100, 1450),持续100ms
adb shell input swipe 100 500 100 500 500 //模拟长按坐标(100, 500),持续500ms
adb shell input keyevent 25 //调低音量,根据AOSP中KeyEvent类中事件常量定义
adb shell am start com.test.app/com.test.app.MainActivity //启动软件com.test.app中的活动 MainActivity
adb shell am start -a "android.intent.action.VIEW" -d "https://www.google.com" //使用隐式intent启动浏览器打开网页,需root
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED //发出启动完成的广播,Android11不允许
adb shell am startservice com.test.app/com.test.app.MyService //启动软件com.test.app中的服务MyService
adb logcat //显示设备当前日志
adb shell dumpsys //查询所有系统信息,包括活动、管理器、界面管理器、输入、电源、进程、电池、闹钟、内存等信息
adb shell dumpsys activity // 查询AMS(ActivityManagerService)信息
adb shell dumpsys package // 查询PMS(PackageManagerService)信息
adb shell dumpsys window // 查询WMS(WindowManagerService)信息
adb shell dumpsys input // 查询IMS(InputManagerService)信息
adb shell dumpsys power // 查询PMS(PowerManagerService)信息
adb shell dumpsys procstats // 进程统计(ProcessStatsService)
adb shell dumpsys battery // 电量信息(BatteryService)
adb shell dumpsys alarm // 闹钟信息(AlarmManagerService)
adb shell dumpsys meminfo //内存信息
adb shell screencap /sdcard/screen.png
adb shell screenrecord /sdcard/screen.mp4
adb shell ps
adb shell top
adb devices
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步