常用的adb command

本文总结一下在工作中经常用到的adb command
1. adb devices: 查看连接的device

adb devices
List of devices attached
emulator-5554 device
emulator-5555 device

2. 安装apk文件

adb install helloWorld.apk

可以指定Android手机的serial number

adb -s emulator-5555 install helloWorld.apk

3. 卸载apk文件

adb uninstall com.example.MyApp

4. adb start-server
5. adb kill-server, 停止adb server
6. adb pull remote local 将文件从Android设备端拷贝到电脑端

adb pull /sdcard/foo.txt /local/

7. adb push local remote 将文件从电脑端拷贝到Android设备sd卡上

adb push foo.txt /sdcard/foo.txt 

8. 删除文件

adb shell rm /sdcard/foo.txt

9. 创建目录

adb shell mkdir -p /sdcard/tmp/test

10. 复制文件

adb shell cp /sdcard/foo.txt /sdcard/tmp

11. adb shell

adb [-d |-e | -s serial_number] shell shell_command

To start an interactive shell on a device use the shell command like this:

adb [-d | -e | -s serial_number] shell

查看系统内存:

adb shell cat /proc/meminfo

查看指定包名应用内存使用情况:

adb shell dumpsys meminfo <package>

To exit an interactive shell, press Control + D or type exit.

12. Call activity manager (am)

am <command>

start [options] intent: start an activity specified by intent

adb shell am start -a android.intent.action.VIEW 

启动应用:

adb shell am start -n <pckagename/activity>

停止应用:

adb shell am force-stop <package>

查看所有的activity:

adb shell dumpsys activity

查找当前的activity

adb shell dumpsys activity | findstr 'mainActivity'

13. Call package manager(pm)
adb shell pm list package 列举package

list packages [options] filter Prints all packages, optionally only
those whose package name contains the text in filter. Options:
-f: See their associated file.
-d: Filter to only show disabled packages.
-e: Filter to only show enabled packages.
-s: Filter to only show system packages.
-3: Filter to only show third party packages.
-i: See the installer for the packages.
-u: Also include uninstalled packages.
–user user_id: The user space to query.

清空指定包名对应胡数据和缓存文件:

adb shell pm clear <packagename>

14. 截图
screencap filename

adb shell screencap /sdcard/screen.jpg
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值