The most detailed, mobile APP test - ADB command summary, everything you want is here...


foreword

What is adb?

The full name of adb is Android Debug Bridge, which is to play the role of debugging bridge. It is a command line window, which is used to interact with the emulator or device through the computer.

What is adb for?

With the help of the adb tool, we can manage the state of the device or phone emulator. You can also perform many mobile phone operations, such as installing software, system upgrades, running shell commands, and so on. In fact, in short, adb is a bridge connecting Android phones and PCs, allowing users to perform comprehensive operations on the phone on the computer.

adb common commands

1. View the currently connected devices

adb devices

Main function: View the currently connected devices, and the Android devices or emulators connected to the computer will be displayed in a list.

Output format:[serialNumber][state]

If there is no emulator or device currently running, adb will return List of devices attached as empty

offline: indicates that the device is not connected to the computer or does not respond
device: the device has been connected to the computer. Note that this state does not mean that the Android device is available. When the Android device is in the startup phase, it will return this state if the connection is successful.

C:\Users\chenshifeng>adb devices
List of devices attached
2cc1bf71        device
30.52.104.12:5555       device

2. Close and start the adb service

adb kill-server //关闭adb服务
adb start-server //启动adb服务

3. Install app
adb install <apk file path>

Commonly used parameters:
adb install –r Overwrite installation
adb install –s Install to SD card
adb install –rs Overwrite install to SD card
adb –s <serial number> installSelected device installation

When there are multiple devices connected, you can use the following command to directly select the device for installation.

adb [-d|-e|-s <serial number>] install <path_to_apk>

d: real device (applicable when there is only one real device among multiple devices)
e: emulator (applicable when there is only one emulator among multiple devices)
s: serial number

adb –d install ./test.apk
adb –s emulator-5556 install ./test.apk

4. Uninstall APP
adb uninstall <package name>

Main function: Uninstall the specified program on the device

Check the package name path: /data/app, system installation package path: /sys/data, the viewing of files under these two paths requires root authority

adb uninstall –k <包名>
adb shell pm uninstall –k <包名>

Uninstall the program but keep its configuration and cache files, that is, the data under /data/data/packname and the data under /sdcard/program name

5. adb push/pull
adb push <local path> <device path>
to copy the files or folders on the PC to the device.

adb push /home/test.apk /sdcard/

adb pull <device path><local path>

Copy files or folders from your device to your computer

adb pull /sdcard/log/test.xls /home/

After the Pull command, you don’t need to enter the local address. If you don’t enter it, the file will be copied to the directory where the current terminal is located.

6.
The main function of adb logcat: view the log and display the debugging information in the command line adb logcat >>
<specified file path> Save the logcat information in the specified file Append
>>overwrite
>

adb logcat –help: View logcat command help documentation

Every log message has a tag and priority associated with it.
The format is: /
Filter logs with different priorities: adb logcat *:W (filter logs with a lower priority than W)
The tag is a short string used to identify the source of the original message (for example, "View" comes from the display system ).

The priority is the following characters, in order from lowest to highest:

V—Verbose 明细(最低优先级)
D—Debug 调试
I—Info 信息
W—Warm 警告
E—Error 错误
F—Fatal 严重错误
S—Silent 无记载(最高优先级,没有什么会被记载)

7. adb shell
Since Android is an operating system based on the Linux kernel. Therefore, shell commands can be executed on Android.

Commonly used commands are as follows:

ls    查看文件夹
cd    改变目录
cat <文件名>    查看文件内容
rm    删除文件
mkdir <文件夹>    新建文件夹
cp    复制文件到另一目录
exit   退出shell命令
adb shell <command>    直接运行设备命令
adb shell su –c “<command>”    直接运行root权限命令
8.adb shell am
am start –n <包名>/<包名>.<Activity名>   启动程序
am force-stop <包名>    强制停止程序
am kill <包名> 杀死与包名有关的后台进程,不影响用户体验,相当于一般的清理内存功能
am kill-all    杀死所有后台进程

9、adb shell pm

pm path <包名>   查看apk安装在手机后的路径
pm uninstall [-k] <包名>  卸载程序(-k:保留配置文件)
pm clear <包名>    清除应用缓存数据

10. Other common commands

adb help    显示帮助信息
adb version   显示adb版本
adb reboot    重启手机
adb shell am broadcast -a android.intent.action.MASTER_CLEAR(恢复出厂)
adb shell dumpsys window | grep init 查看手机的分辨率
adb logcat -s ActivityManager        Activity的启动时间
The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

Take the first step bravely, don't be afraid to fail, and don't stop. Embrace challenges, surpass yourself, and the journey of struggle will shape the stage where dreams come true. Be firm and persistent, burn passion, let every day shine with the light of hope, and create your own brilliant life.

Suffering is the catalyst for growth, and unyielding is the attitude of struggle. Adhere to the belief, chase the dream, water the hope with sweat, and create brilliance with hard work. Every struggle is a feat in life, let us pursue bravely and create our own great legend.

Embrace challenges, defy difficulties, and move forward bravely. Struggle is the proof of blood, and struggle is the source of strength. Keep your feet on the ground, take every step, let hard work become your confidence, ignite the passion in your heart, and create your own glorious road.

Guess you like

Origin blog.csdn.net/x2waiwai/article/details/132173792