The ADB command uses

Source: Internet
Author: User
Tags memory usage cpu usage disk usage

Extract the contents of Anly_jun in Jane's book

1, Introduction to ADB

ADB full name Andorid Debug Bridge. As the name implies, this is a debug tool.
But why is it called bridge? Because ADB is a standard CS structure tool, it is to connect the development computer and your debug phone. Contains the following sections:

    • Client side, running in the development machine, that is, your development PC. Used to send ADB commands.
    • The Deamon daemon, running on the debug device, is the debug phone or emulator.
    • Server side, as a background process running in the development machine, that is, your development PC. Used to manage communication between the client side of the PC and the deamon of the phone.
2, common usage 2.1 adb devices

Enumerate the currently connected debug devices

$ adb devicesList of devices attachedDU2SSE1467010378    device
2.2 ADB Logcat

Print log information

instruction Description Notes
ADB logcat Print Log /
ADB logcat-c Clear the phone's log buffer Some mobile rights control, not supported.
ADB logcat-b <buffer> Print log information for specified buffer Buffer: Main (main log area, default), events (event-related log), radio (RF, telephony related log)
ADB logcat-v <format> Formatted output log Common use of ADB logcat-v time display
ADB logcat-f <filename> Output log to the specified file
2.3 adb Install/uninstall

Ann Loading APK

// 安装apk时指定apk file路径$ adb install ~/Downloads/mobileqq_android.apk[100%] /data/local/tmp/mobileqq_android.apk    pkg: /data/local/tmp/mobileqq_android.apkSuccess// 卸载apk时指定包名$ adb uninstall com.tencent.mobileqqSuccess
2.4 adb Pull/push

Copy files between the debug device and the development PC.

// 拷贝本地文件到调试设备中$ adb push ~/temp/GithubApp.trace /sdcard/[100%] /sdcard/GithubApp.trace// 从调试设备中拷贝文件到本地$ adb pull /sdcard/GithubApp.trace ~/[100%] /sdcard/GithubApp.trace
2.5 adb Start/kill-server

Start/Kill the server-side process mentioned in the ADB profile.

Because the ADB is not stable, sometimes inexplicable problems fall off the line, you can first Kill-server, and then start-server to ensure that the server process starts. can often solve problems.

2.5 adb shell

Enter the shell interface of the debug device, where you can use many of the instructions in the debug device. Many of the higher-order uses below are.

$ adb shellshell@hwH60:/ $
3, high-order Usage 3.1 adb connect/disconnect

Remotely connect to the phone via WiFi for debugging.
Https://developer.android.com/studio/command-line/adb.html#wireless

To start the remote debugging mode, connect the USB mode first:
$ adb tcpip 5555

3.2 adb shell AM

AM is activity Manager.
This command is used to perform some system actions, such as starting a specified activity, ending a process, sending a broadcast, changing screen properties, and so on. Debugging tool.

instruction Description Notes
start <intent> to start activity according to Intent Intent can be a display point to activity or action mode. And can add flag, data and other parameter information.
startservice <intent> start service to add parameter information such as flag, data, and so on.
broadcast <intent> send broadcast You can add parameter information such as flag, data, and so on.
Monitor start a crash and ANR listener If you have crash or ANR, the information will be output from the console.
force-stop <package> Force stop all relevant incoming package name.
kill <package> kill all processes related to the package incoming packages name.
kill-all kill all background processes  
display-size WxH Change the displayed Resolution For example, adb shell am display-size 1280x720, the phone may not be supported.
display-density <dpi> Change the displayed density For example ADB shell am display-density 320, the phone may not Support.
3.3 adb shell PM

PM is the package Manager.
Used to perform package-related operations, such as loading and unloading, querying system installation packages, etc.

instruction Description Notes
List Packages <Filter> List all packages that meet the filter criteria
List Permissions <Group> List all permissions for this group
List features See which feature the system supports such as Bluetooth, WiFi, camera and so on.
Install <path>/uninstall <Package> Safety Loading and unloading
Clear <Package> Clear App Data
3.4 adb Shell Screencap

Screenshot, more convenient and faster than the screenshot shortcut keys.

shell screencap /sdcard/screen.png$ adb pull /sdcard/screen.png ~/temp[100%] /sdcard/screen.png
3.5 adb shell Screenrecord

Recording screen, do the demo, you can easily use this name to record the video, and then use the tool to convert it into a gif, awesome. As follows:


Screenrecord gif

Android4.4 and above systems are available.

2.5 adb shell Dumpsys

Powerful dump tool that can output a lot of system information. such as window, activity, task/back stack information, wifi information, etc.

Explore the launchmode of activity and explore the start of activity intent flag and affinity are used to export task information using the ADB shell dumpsys activity.

Common Dumpsys:

instruction Description Notes Subdivision Parameters
Activity Output app component related information You can also use the subdivision parameters to obtain a single content, the same. For example, the ADB shell dumpsys activity activities to get activity task/back stack information. Activites, service, providers, intents, broadcasts, processes
Alarm Output alarm information for the current system / /
Cpuinfo Output Current CPU Usage / /
Diskstats Output the current disk usage status / /
Batterystats Battery usage information / /
Package Package-related information, equivalent to a collection of PM functions Output information such as Libs, features, packages, etc. /
Meminfo Output memory usage and system memory status for each app You can specify the package name, such as adb shell Dumpsys meminfo Com.anly.githubapp /
Window Output current Window related information / Policy, animator, tokens, windows

---restore content ends---

1, Introduction to ADB

ADB full name Andorid Debug Bridge. As the name implies, this is a debug tool.
But why is it called bridge? Because ADB is a standard CS structure tool, it is to connect the development computer and your debug phone. Contains the following sections:

    • Client side, running in the development machine, that is, your development PC. Used to send ADB commands.
    • The Deamon daemon, running on the debug device, is the debug phone or emulator.
    • Server side, as a background process running in the development machine, that is, your development PC. Used to manage communication between the client side of the PC and the deamon of the phone.
2, common usage 2.1 adb devices

Enumerate the currently connected debug devices

$ adb devicesList of devices attachedDU2SSE1467010378    device
2.2 ADB Logcat

Print log information

instruction Description Notes
ADB logcat Print Log /
ADB logcat-c Clear the phone's log buffer Some mobile rights control, not supported.
ADB logcat-b <buffer> Print log information for specified buffer Buffer: Main (main log area, default), events (event-related log), radio (RF, telephony related log)
ADB logcat-v <format> Formatted output log Common use of ADB logcat-v time display
ADB logcat-f <filename> Output log to the specified file
2.3 adb Install/uninstall

Ann Loading APK

// 安装apk时指定apk file路径$ adb install ~/Downloads/mobileqq_android.apk[100%] /data/local/tmp/mobileqq_android.apk    pkg: /data/local/tmp/mobileqq_android.apkSuccess// 卸载apk时指定包名$ adb uninstall com.tencent.mobileqqSuccess
2.4 adb Pull/push

Copy files between the debug device and the development PC.

// 拷贝本地文件到调试设备中$ adb push ~/temp/GithubApp.trace /sdcard/[100%] /sdcard/GithubApp.trace// 从调试设备中拷贝文件到本地$ adb pull /sdcard/GithubApp.trace ~/[100%] /sdcard/GithubApp.trace
2.5 adb Start/kill-server

Start/Kill the server-side process mentioned in the ADB profile.

Because the ADB is not stable, sometimes inexplicable problems fall off the line, you can first Kill-server, and then start-server to ensure that the server process starts. can often solve problems.

2.5 adb shell

Enter the shell interface of the debug device, where you can use many of the instructions in the debug device. Many of the higher-order uses below are.

$ adb shellshell@hwH60:/ $
3, high-order Usage 3.1 adb connect/disconnect

Remotely connect to the phone via WiFi for debugging.
Https://developer.android.com/studio/command-line/adb.html#wireless

To start the remote debugging mode, connect the USB mode first:
$ adb tcpip 5555

3.2 adb shell AM

AM is activity Manager.
This command is used to perform some system actions, such as starting a specified activity, ending a process, sending a broadcast, changing screen properties, and so on. Debugging tool.

instruction Description Notes
start <intent> to start activity according to Intent Intent can be a display point to activity or action mode. And can add flag, data and other parameter information.
startservice <intent> start service to add parameter information such as flag, data, and so on.
broadcast <intent> send broadcast You can add parameter information such as flag, data, and so on.
Monitor start a crash and ANR listener If you have crash or ANR, the information will be output from the console.
force-stop <package> Force stop all relevant incoming package name.
kill <package> kill all processes related to the package incoming packages name.
kill-all kill all background processes  
display-size WxH Change the displayed Resolution For example, adb shell am display-size 1280x720, the phone may not be supported.
display-density <dpi> Change the displayed density For example ADB shell am display-density 320, the phone may not Support.
3.3 adb shell PM

PM is the package Manager.
Used to perform package-related operations, such as loading and unloading, querying system installation packages, etc.

instruction Description Notes
List Packages <Filter> List all packages that meet the filter criteria
List Permissions <Group> List all permissions for this group
List features See which feature the system supports such as Bluetooth, WiFi, camera and so on.
Install <path>/uninstall <Package> Safety Loading and unloading
Clear <Package> Clear App Data
3.4 adb Shell Screencap

Screenshot, more convenient and faster than the screenshot shortcut keys.

shell screencap /sdcard/screen.png$ adb pull /sdcard/screen.png ~/temp[100%] /sdcard/screen.png
3.5 adb shell Screenrecord

Recording screen, do the demo, you can easily use this name to record the video, and then use the tool to convert it into a gif, awesome. As follows:


Screenrecord gif

Android4.4 and above systems are available.

2.5 adb shell Dumpsys

Powerful dump tool that can output a lot of system information. such as window, activity, task/back stack information, wifi information, etc.

Explore the launchmode of activity and explore the start of activity intent flag and affinity are used to export task information using the ADB shell dumpsys activity.

Common Dumpsys:

instruction Description Notes Subdivision Parameters
Activity Output app component related information You can also use the subdivision parameters to obtain a single content, the same. For example, the ADB shell dumpsys activity activities to get activity task/back stack information. Activites, service, providers, intents, broadcasts, processes
Alarm Output alarm information for the current system / /
Cpuinfo Output Current CPU Usage / /
Diskstats Output the current disk usage status / /
Batterystats Battery usage information / /
Package Package-related information, equivalent to a collection of PM functions Output information such as Libs, features, packages, etc. /
Meminfo Output memory usage and system memory status for each app You can specify the package name, such as adb shell Dumpsys meminfo Com.anly.githubapp /
Window Output current Window related information / Policy, animator, tokens, windows

The ADB command uses

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.