常用的ADB/AAPT命令

本文介绍了如何使用ADB命令行工具进行各种安卓设备管理操作,包括获取APP包名、系统版本、查看连接设备、启动应用、获取当前界面元素、任务列表、关闭应用、安装/卸载APK、复制文件到设备等。这些技巧对于安卓开发者和测试人员来说非常实用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.获取APP包名

  • adb命令获取包名
    1)启动APP
    2)
    wins: adb shell dumpsys window | findstr mCurrentFocus
    mac: adb shell dumpsys window |grep mCurrentFocus
  • aapt命令获取包名
    aapt dump badging + apk所在的绝对路径 + apk文件名称

2.获取系统版本
adb shell getprop ro.build.version.release

3.查看连接的设备
adb devices

3.连接安卓机器
一台机器:
adb shell
多台机器:
adb -s 192.168.57.105:5555 shell getprop ro.build.version.release

4.获取apk 入口Activity

  • aapt dump badging 加apk的路径 加竖线 | findstr launchable-activity
  • adb logcat | grep -i displayed

5.获取当前界面元素
adb shell dumpsys activity top

6.获取任务列表
adb shell dumpsys activity activities

7.关闭应用
adb shell pm clear $package;
adb shell pm force-stop $package;

8.启动应用
adb shell am start -S -W $package/Activity名称

9.安装/卸载apk
adb -s emulator-5555 install helloWorld.apk
adb shell pm uninstall com.example.MyApp

10.复制某个文件或目录
adb pull remote local

11.将某个文件或目录(及其子目录)复制到设备
adb push local remote

链接:https://developer.android.google.cn/studio/command-line/adb?hl=zh-cn

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值