appium --- common adb commands

  In the test android-app time, adb command can help us solve many problems

 

What is adb

Android  Debug Bridge, we generally referred to as the adb, mainly located in the platform-tools installation directory files in sdk folder, it is a very powerful command-line tool, you can interact with your android device through this tool.

 

Common adb commands

format:

adb [-d|-e|-s <serialNumber>] <command>

- d: Let the only real Android devices execute commands to connect to the PC side, USB connection a number of the equipment if found, will be thrown

- E: Let the only simulator connected to the PC side of the command execution, if found to open multiple simulators, will be thrown

- S: designating execution command through the device's serial number

If the device is only connected to a device or a simulator, you can not declare these three parameters, adb default this will be the only device connected to the command execution.

 

1, view device:

adb devices

 

2, install app

adb install APK path

 

 

3, uninstall app

adb uninstall apk's package name

 

4, see the apk's package name

# 1: Open the apk you want to query
adb logcat | find “START”

# Method 2: aapt tool 
aapt dump badging apk path

 

5, how to save device logs

# Save all log 
adb logcat   > computer path

# 保存单个apk日志
adb logcat | find ”包名“ >电脑路径

 

6、重启/杀死adb进程

# 杀掉adb进程
 adb kill-server

# 重启adb服务
 adb start-server

 

7、传输文件

# 电脑发文件到手机
adb push <电脑路径> <手机路径>

# 手机发文件到电脑
adb pull  <手机路径> <电脑路径>

 

8、监控app服务

# 监控app的内存变化
adb shell dumpsys meminfo  包名

# 监控app的cpu
adb  shell dumpsys cpuinfo | find ”包名“

# 监控app的耗电量
adb shell dumpsys battery

 

9、辅助命令

# 截图命令
adb shell screencap -p /手机路径 (sdcard/screen.png)

# 录制视频
adb shell screenrecord  /手机路径/XXX.MP4

 

10、monkey命令

# monkey命令

adb shell monkey –p 包名 100

# Adb shell 这个是进入android的shell环境  
# Monkey  这个是调用shell里面的monkey工具  (monkey是每个手机出场自带的,我们输入指令是去唤醒它)
# -p 包名
# 100是点击的次数

 

11、重启设备

# 重启设备
adb reboot

# 恢复出厂设置
adb reboot recovery 

 

Guess you like

Origin www.cnblogs.com/qican/p/11078412.html