adb常用命令(一)

adb shell 进入设备目录

1. 启动和关闭adb服务

  adb kill-server 关闭adb服务

  adb start-server 启动adb服务

2. 查看设备连接情况

  adb devices 

  adb devices -l

  当有多台设备时

  使用命令 adb -s 192.168.0.102:555 shell

  进入对应的设备

  连接对应的设备

    adb connect 192.168.8.102:555

3. 安装和卸载APK程序

  adb install <apk文件路径>

    将指定的apk文件安装到设备上

  adb uninstall <软件名> 

    使用 appt dump badging xxx.apk 查看包名

  卸载设备上的指定程序

  adb uninstall -k <软件名>

    卸载程序但是保留其配置和缓存文件

  查看手机安装包列表

    adb shell pm list packages

4. 指定设备进行操作

  当有多个设备连接时,选择指定设备来执行对应命令

  adb [-d | -e | -s <serial Number>] <command>

  -d:指定当前唯一通过 USB 连接的 Android 设备为命令目标  (多个设备中只有一个真机时使用)

  -e:指定当前唯一运行的模拟器为命令目标(多个设备中只有一个模拟器时适用)

  -s:系列号<serialNumber>指定相应 serialNumber 号的设备/模拟器为命令目标

  例如: adb -d install helloworld.apk

      adb -s emulator-5566 install hellowrold.apk

5.进入设备Shell

  adb shell

  退出设备

  exit + 回车  

  不进入设备,只执行一条命令

  adb shell [command]

  手机需要root,不然无法进入shell状态下

6. 上传和下载文件

  adb push <本地路径> <远程路径>

  adb push foo.txt  /sdcard/foo.txt

  adb pull <远程路径> <本地路径>

  adb push system/app D:apps

7. 查看设备日志

  adb logcat

  adb logcat > c:a.txt  将日志下载到本地目录

8. 安卓命令

  android sdk 查看安装sdk信息

  android avd 查看安装原生模拟器

  android list avd 查看模拟器信息列表

9. 连接设备

  adb connect 127.0.0.1:62001

10. 获取手机系列号:

    adb get-serialno

11. 获取和取消root权限

  以root权限运行adb

    adb root

  取消root权限

    adb unroot

12. 指定adb server的网络端口

  #adb 默认端口为5037

  adb -P <port> start-server

原文地址:https://www.cnblogs.com/zxh06820/p/14656058.html