Android adb do you really want to use it?

Source: Internet
Author: User
Tags disk usage

Objective

This article is based on the official Android documentation, as well as the use of personal work experience, summed up the common use of the ADB, memo.

1.ADB Introduction

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:

    • The client side, which runs on the development machine, your development PC, is used to send ADB commands.
    • The Deamon daemon, which runs on the debug device, is the debug phone or emulator.
    • Server side, as a background process runs in the development machine, i.e. 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

2.2 ADB Logcat

Print log information

Instructions Description Note
ADB logcat Print Log /
ADB logcat-c Clear the phone's log buffer Some mobile rights control, do not support
ADB logcat-b<buffer> Print log information for specified buffer

Buffer has: 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 Shell CD data/data/ - LS

Get all App package names

2.4 adb Install/uninstall

Ann Loading APK

2.5 adb Pull/push

Copy files between the debug device and the development PC

// 拷贝本地文件到调试设备中

// 拷贝本地文件到调试设备中

2.6 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.

3. Higher-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.

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:

Android4.4 and above systems are available.

3.6 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

Android adb do you really want to use it?

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.