Common ADB commands and logcat usage

Source: Internet
Author: User
Tags grep regular expression

Several commands commonly used by ADB
1. View Devices
ADB Devices
This command is used to view the currently connected devices. The Android devices or simulators connected to the computer are listed and displayed.

2. Install Software Uninstall
ADB install <APK file path>
ADB uninstall <software Name>

4. log on to the device Shell
ADB Shell
ADB shell <command>
This command will log on to the shell of the device.
The <command> command is used to directly run the device command, which is equivalent to executing the remote command.

5. Send files to the device from the computer
ADB push <local path> <remote path>
Use the push command to copy files or folders on the local computer to the device (mobile phone)

6. download files from your device to your computer
ADB pull <remote path> <local path>
Run the pull command to copy files or folders on the device (mobile phone) to the local computer.

7. Get the root permission of the device
ADB remount

2. Log method:
Common android. util. Log methods include log. V () log. D () log. I () log. W () and log. E (). Corresponds to verbose, debug, info, warn, and error according to the first letter.

1. the debugging color of log. V is black, and any message will be output. Here v stands for verbose, which is usually used as log. V ("","");

2. The output color of log. D is blue and only the meaning of DEBUG debugging is output. However, it outputs the upper-layer information, which can be selected through the logcat tag of ddms.

3. The output of log. I is green. Generally, it indicates message information. It does not output information of log. V and log. D, but displays information of I, W, and E.

4. log. W indicates orange. It can be seen as a warning of warning. We need to pay attention to optimizing android.CodeAnd then output log. e information.

5. If log. e is red, you can think of error errors. Here, only red error messages are displayed. We need to carefully analyze these errors and view stack information.

Three ADB log Filtering:

1. Only display the required output, whitelist
The most convenient of course is to use grep to filter through the pipeline, so that you can use the powerful grep regular expression to match. Simply match a string in a row, such as MyApp:
ADB logcat | grep MyApp
ADB logcat | grep-I MyApp # case insensitive.

2. Save log
The-D parameter can be used to return results after reading all logs without waiting for them. It is useful in automation. For example:
ADB logcat-d-s XXX> XXX. Log // obtain the log whose filter is XXX, store it in XXX. log, and return.

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.