Android adb常用的命令

简介

下面介绍一下Android开发中常用的adb命令,给Android程序员带来非常便利的开发命令工具,我们来使用一下吧。记录一下常用的命令

1.获取adb命令帮助,查看全部命令简介

$ adb help

如下:

Android Debug Bridge version 1.0.41
Version 30.0.3-6597393
Installed as /Users/***/Library/Android/sdk/platform-tools/adb

global options:
 -a         listen on all network interfaces, not just localhost
 -d         use USB device (error if multiple devices connected)
 -e         use TCP/IP device (error if multiple TCP/IP devices available)
 -s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)
 -t ID      use device with given transport id
 -H         name of adb server host [default=localhost]
 -P         port of adb server [default=5037]
 -L SOCKET  listen on given socket for adb server [default=tcp:localhost:5037]

2.获取adb版本

$ adb version

输出如下:

Android Debug Bridge version 1.0.41
Version 30.0.3-6597393

3.获取设备

$ adb devices

输出如下:

List of devices attached
1211313 device
xxxxxhh device

4.默认安装当前只有一个设备时

$ adb install test.apk

5.如果多个设备时,先获取设备,如3.然后在使用

$ adb -s 1211313 install test.apk

6.启动服务/停止服务

$ adb start-server
$ adb kill-server

7.获取项目的包

$ adb shell pm list packages

8.卸载当前应用,根据包名进行卸载

$ adb uninstall [-k]  

如下:

$ adb uninstall com.icon.test

9.清除数据和缓存

$ adb shell pm clear 

如下:

$ adb shell pm clear com.icon.test

10.查看前台的activity

$ adb shell dumpsys activity activities | grep mFocusedActivity

11.查看services

$ adb shell dumpsys activity services []

12.查看安装路径

$ adb shell pm path 

如下:

adb shell pm path com.icon.test

你可能感兴趣的:(Android adb常用的命令)