Common commands of Android's powerful native debugging tool adb

Introduction to ADB

ADB (Android Debug Bridge) is a command-line tool for communicating with and debugging Android devices. The following are some commonly used ADB debugging commands:

Common commands

list linked devices

adb devices: Lists the Android devices connected to the computer.
insert image description here
You can see that I have connected two devices here.

Enter the shell environment of the device

adb shell: Enter the command line shell environment of the device, and execute various commands on the device.
insert image description here
After entering, we can execute various commands, as shown above

device log

adb logcat: Display device log information, including application output, system messages, and error logs.
insert image description here
When using the adb logcat command to view the log information of the device, to exit the logcat output, you can press the Ctrl + C key combination (on Windows systems), or use the Ctrl + Z key combination (on Linux and Mac systems) to terminate the running The command to run.

After pressing the corresponding key combination, the adb logcat command will stop outputting logs, and return to the command line prompt, and exit logcat for viewing.

install the application

adb install <path_to_apk>: Install the application (APK file) to the device.

Directly follow the packaged apk to the debugging device, as shown in the figure:
insert image description here

uninstall application

adb uninstall <package_name>: Uninstall the application with the specified package name.
insert image description here

Copy local files to debug device

adb push <local_file> <device_path>: Copy the local file to the specified path on the device.

Pull the files on the device to the local

adb pull <device_path> <local_path>: Copy the file on the device to the local path.
adb pull /sdcard/<file_path> <local_path>: Copy files from the SD card of the device to the local path.

starting program

adb shell am start -n <package_name>/<activity_name>: Start the application with the specified package name and Activity name.

Forcibly stop the program from running

adb shell am force-stop <package_name>: Force stop the application with the specified package name.

screenshot

adb shell screencap <file_path>: Take a screenshot on the device and save it to the specified file path.

screen recording

adb shell screenrecord <file_path>: Record the screen on the device and save the recording to the specified file path.
insert image description here

List all application registrations for the debugging device

adb shell pm list packages: List all application package names installed on the device.
insert image description here

epilogue

This is just a sample of some common ADB debugging commands, ADB provides many more commands and options for deeper debugging and development tasks. You can get more detailed information and usage by running the adb --help command or referring to the official documentation of ADB.

Basically, flexible use of the above commands can meet 60% of the basic debugging requirements.

Guess you like

Origin blog.csdn.net/yikezhuixun/article/details/131330992