"Android" Android common ADB and adb shell commands

Source: Internet
Author: User

The DB is the SDK comes with the tool, can realize the bridge function;
ADB shell can interact with the mobile phone system, based on the operation of the Andoid Linux system

adb common commands:

1. View the device
ADB devices
This command is to view the currently connected device, the Android device connected to the computer, or the emulator will list the display

2. Installing the Software
ADB install <apk file path >
This command installs the specified APK file on the device
Parameter "-R", which is the meaning of the update installation,
Parameter-S, installed to SDcard.
Example: adb install com.sina.weibo.apk

3. Uninstalling the Software
ADB Uninstall < package name >
If you add the-K parameter, the software is uninstalled but the configuration and cache files are preserved.
such as: adb uninstall com.sina.weibo.apk

4. Log in to the device shell
ADB shell
Adbshell <command Command >
This command will log into the device's shell.
The following add <command command > will be run directly on the device command, equivalent to executing a remote command
such as: adb shell cat/proc/kmsg

5. Send files from the computer to the device
ADB Push < Local path > < remote path >
Use the push command to copy files or folders on your computer to your device (mobile)
such as: ADB Push/local/build.prop/system/build.prop

6. Download files from the device to the computer
ADB pull < Remote path > < local path >
Use the pull command to copy files or folders on your device (phone) to your local computer
such as: adb/system/build.prop/local/

7. Synchronizing Updates
ADB sync [<directory>]
If you do not specify a directory, both/data and/system/are updated
such as: ADB sync/data/

8. Display Help information
ADB Help
This command will display the Help information

9. Re-mount
ADB remount
Re-mount the system partition for read-write

10. Start and close
ADB start-server-ensure that there is a server running
ADB Kill-server-kill the server if it is running

11. Restart the device
ADB reboot [Bootloader|recovery]-reboots the device, optionally into the bootloader or recovery program


12. View Log
[ADB] logcat [<option>] ... [<filter-spec>]..
-B <buffer> Loads a log buffer that can be used for viewing, such as event and radio. The default value is main. See Viewing alternative Log buffers specifically.
-C Clear the Log on the screen.
-D output logs to the screen.
-F <filename> Specifies the <filename> of the output log information, which is stdout by default.
-g outputs the specified log buffer and exits after output.
-N <count> sets the maximum number of logs <count>., the default value is 4 and needs to be used with the-r option.
-R <kbytes> output log per <kbytes>, default value is 16 and needs to be used with the-f option.
-S sets the default filter level to silent.
-V <format> Set the log input format, the default is brief format

Where <tag> is a log component tag (or * for all) and the IS:
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent (supress all output)

' * ' means ' *:d ' and <tag> by itself means <tag>:v


13. Check the bug report:
ADB bugreport












common adb shell commands:

1. Key events
Input text <string> input a string to device
Input KeyEvent <event_code> send a Key event to device
Example: adb shell input keyevent (Powerkey)

2. Am command
Am Start <INTENT>: Start an Activity
Such as:
Am Start-n Com.android.calculator/com.android.calculator2.calculator

AM Broadcast <INTENT>

Am StartService <INTENT>
Am Force-stop <PACKAGE>
Am Kill <PACKAGE>
Am Kill-all
AM Broadcast <INTENT>

"<INTENT> specifications include these flags and arguments:\n" +
"[-a <action>] [-D ] [-t <mime_type>]\n" +
"[-C <CATEGORY> [-C <category>] ...] \ n "+
"[-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...] \ n "+
"[--esn <EXTRA_KEY> ...] \ n "+
"[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...] \ n "+
"[--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...] \ n "+
"[--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...] \ n "+
"[--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...] \ n "+
"[--eia <EXTRA_KEY> <extra_int_value>[,<extra_int_value ...]] \ n "+
"[--ela <EXTRA_KEY> <extra_long_value>[,<extra_long_value ...]] \ n "
"[-N <component>] [-F <flags>]\n" +
"[--grant-read-uri-permission] [--grant-write-uri-permission]\n" +
"[--debug-log-resolution] [--exclude-stopped-packages]\n" +
"[--include-stopped-packages]\n" +
"[--activity-brought-to-front] [--activity-clear-top]\n" +
"[--activity-clear-when-task-reset] [--activity-exclude-from-recents]\n" +
"[--activity-launched-from-history] [--activity-multiple-task]\n" +
"[--activity-no-animation] [--activity-no-history]\n" +
"[--activity-no-user-action] [--activity-previous-is-top]\n" +
"[--activity-reorder-to-front] [--activity-reset-task-if-needed]\n" +
"[--activity-single-top] [--activity-clear-task]\n" +
"[--activity-task-on-home]\n" +
"[--receiver-registered-only] [--receiver-replace-pending]\n" +
"[--selector]\n" +
"[<uri> | <PACKAGE> | <component>]\n "

For more detailed usage please see AM use Help.

3. PM command
PM List Packages
-f:see their associated file
-s:filter to only show system packages
-3 Ilter to the show third party packages
PM list packages [-F] [-d] [-e] [-S] [-e] [-u] [FILTER] ");
PM List permission-groups
PM List permissions [-G] [-f] [-d] [-u] [GROUP] ");
PM list instrumentation [-f] [target-package] ");
PM List Features
PM List Libraries
PM Path Package
PM install [-l] [-r] [-T] [-I installer_package_name] [-S] [-f] PATH
PM Uninstall [-K] Package
PM Clear Package
PM Enable Package_or_component
PM Disable Package_or_component
PM Disable-user package_or_component
PM Set-install-location [0/auto] [1/internal] [2/external]
PM Get-install-location

For more detailed usage, see PM use Help.

4. Dumpsys
Dumpsys Activit
Dumpsys activity intents
Dumpsys Activity Broadcasts
Dumpsys Activity Providers
Dumpsys Activity Services
Dumpsys Activity Activities
Dumpsys Activity Processes

Dumpsys window
Dumpsys window windows
Dumpsys window Tokens
Dumpsys Window Sessions
Dumpsys window Policy
Dumpsys window Input

Dumpsys StatusBar
Dumpsys notification
Dumpsys Package [<package>]
Dumpsys Location
Dumpsys Alarm
Dumpsys Connectivity
Dumpsys WiFi
....... Wait a minute


5. IME Input Method Management
IME list [-a] [-s]
List command prints all enabled input methods
-s option to see only a single summary line for each.
-a option to see all Input method

IME Enable ID
IME Disable ID
IME Set ID

"Android" Android common ADB and adb shell commands

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.