ADB [Android Debug Bridge](https://developer.android.com/studio/command-line/adb.html), it is not only irreplaceable powerful tool for Android developers/testers, but also a good toy to play with Android devices.
ADB ([Android Debug Bridge](https://developer.android.com/studio/command-line/adb.html)), it is not only irreplaceable powerful tool for Android developers/testers, but also a good toy to play with Android devices.
This repo is continuously updated, if you found mistake/issue please create issue or create pull request.
This repo is continuously updated, if you found mistake/issue please create issue or create pull request.
If you found that info useful [this GitHub repository](https://github.com/mzlogin/awesome-adb) please star this repo.
Thanks.
**Note:** There may be supported by part of the command and the version of Android and custom ROM implementation-dependent.
If you found [this GitHub repository](https://github.com/mzlogin/awesome-adb) is useful, please star this repo. Thanks.
#![Table of Contents](./assets/toc.png)
**Note:** Some commands may not supported well depends on the version of Android and ROM.
Other languages:
* [Chinese](./README.md)
#![Table of Contents](./assets/toc.png)
<!-- vim-markdown-toc GFM -->
<!-- vim-markdown-toc GFM -->
* [Basic Usage](#Basic Usage)
* [Basic Usage](#basic-usage)
* [Command Syntax](#command syntax)
* [Command syntax](#command-syntax)
* [Targeting equipment for command](#targeting equipment for command)
* [Targeting equipment for command](#targeting-equipment-for-command)
* [Start / stop](#start stop)
* [Start/Stop](#startstop)
* [See adb version](#View -adb- version)
* [View adb version](#view-adb-version)
* [Running as root adbd](#-root- permission to run -adbd)
* [Run adbd as root](#run-adbd-as-root)
* [Specify adb server network port](#designated -adb-server- network port)
* [Designated adb server network port](#designated-adb-server-network-port)
| -d | Specifies currently the only Android device USB connector as the command target |
| -d | Specifies currently the only Android device USB connector as the command target |
| -e | Specify currently the only goal for the command to run the simulator |
| -e | Specify currently the only goal for the command to run the simulator |
| `-s <SerialNumber>` | Specifies the device number corresponding serialNumber / simulator command target |
| `-s <SerialNumber>` | Specifies the device number corresponding serialNumber / simulator command target |
In the case of multiple devices / simulators are connected to the more common `-s <serialNumber>` parameters, serialNumber can be obtained through `adb devices` command. Such as:
In the case of multiple devices / simulators are connected to the more common `-s <serialNumber>` parameters, serialNumber can be obtained through `adb devices` command. Such as:
@ -170,7 +140,7 @@ Android Debug Bridge version 1.0.36
Revision 8f855a3d9b35-android
Revision 8f855a3d9b35-android
```
```
### To run as root adbd
### Run adbd as root
The operating principle is adb adb server daemon and the phone side PC side adbd establish a connection, then the PC side adb client via adb server forward command parsing after running adbd receive commands.
The operating principle is adb adb server daemon and the phone side PC side adbd establish a connection, then the PC side adb client via adb server forward command parsing after running adbd receive commands.
@ -301,7 +271,7 @@ Steps:
5. Find the IP address of the device.
5. Find the IP address of the device.
Generally the 'Settings' in - "About phone" - "state information" - "IP address" is found, you can also use the following in the [View device information - IP address][1] a Lane method adb command.
Generally the 'Settings' in - "About phone" - "state information" - "IP address" is found, you can also use the following in the [View device information - IP address][1] a Lane method adb command.
6. Connect the device via IP address.
6. Connect the device via IP address.
@ -360,7 +330,7 @@ Since we want to achieve a wireless connection, it can all step down are wireles
4. Find the IP address of the Android device.
4. Find the IP address of the Android device.
Generally the 'Settings' in - "About phone" - "state information" - "IP address" is found, you can also use the following in the [View device information - IP address][1] a Lane method adb command.
Generally the 'Settings' in - "About phone" - "state information" - "IP address" is found, you can also use the following in the [View device information - IP address][1] a Lane method adb command.
5. Connect Android device on a computer via adb and IP addresses.
5. Connect Android device on a computer via adb and IP addresses.
That is the basis of `adb shell pm list packages` can add some parameters on the filter to view different lists, supports filtering parameters are as follows:
That is the basis of `adb shell pm list packages` can add some parameters on the filter to view different lists, supports filtering parameters are as follows:
| `<FILTER>` | package name contains `<FILTER>` strings |
| `<FILTER>` | package name contains `<FILTER>` strings |
#### All applications
#### All applications
@ -464,14 +434,14 @@ parameter:
`Adb install` may be followed by some optional parameters to control the behavior of the installation APK, available parameters and their meanings are as follows:
`Adb install` may be followed by some optional parameters to control the behavior of the installation APK, available parameters and their meanings are as follows:
| INSTALL\_FAILED\_INVALID\_URI | invalid filename APK | APK file names to ensure no Chinese |
| INSTALL\_FAILED\_INVALID\_URI | invalid filename APK | APK file names to ensure no Chinese |
| INSTALL\_FAILED\_INSUFFICIENT\_STORAGE | lack of space | cleanup space |
| INSTALL\_FAILED\_INSUFFICIENT\_STORAGE | lack of space | cleanup space |
| INSTALL\_FAILED\_DUPLICATE\_PACKAGE | program of the same name already exists | |
| INSTALL\_FAILED\_DUPLICATE\_PACKAGE | program of the same name already exists | |
| INSTALL\_FAILED\_NO\_SHARED\_USER | shared user requested does not exist | |
| INSTALL\_FAILED\_NO\_SHARED\_USER | shared user requested does not exist | |
| INSTALL\_FAILED\_UPDATE\_INCOMPATIBLE | already installed signature is not the same application with the same name, and the data is not removed | |
| INSTALL\_FAILED\_UPDATE\_INCOMPATIBLE | already installed signature is not the same application with the same name, and the data is not removed | |
| INSTALL\_FAILED\_SHARED\_USER\_INCOMPATIBLE | shared user request exists but the signatures do not match | |
| INSTALL\_FAILED\_SHARED\_USER\_INCOMPATIBLE | shared user request exists but the signatures do not match | |
| INSTALL\_FAILED\_MISSING\_SHARED\_LIBRARY | installation package used on the device unusable shared library | |
| INSTALL\_FAILED\_MISSING\_SHARED\_LIBRARY | installation package used on the device unusable shared library | |
| INSTALL\_FAILED\_REPLACE\_COULDNT\_DELETE | can not be deleted when replacing | |
| INSTALL\_FAILED\_REPLACE\_COULDNT\_DELETE | can not be deleted when replacing | |
| INSTALL\_FAILED\_DEXOPT | dex optimization validation failure or lack of space | |
| INSTALL\_FAILED\_DEXOPT | dex optimization validation failure or lack of space | |
| INSTALL\_FAILED\_OLDER\_SDK | equipment system version is lower than the application requirements | |
| INSTALL\_FAILED\_OLDER\_SDK | equipment system version is lower than the application requirements | |
| INSTALL\_FAILED\_CONFLICTING\_PROVIDER | equipment already exists with the same name in application content provider | |
| INSTALL\_FAILED\_CONFLICTING\_PROVIDER | equipment already exists with the same name in application content provider | |
| INSTALL\_FAILED\_NEWER\_SDK | equipment system version higher than the application requirements | |
| INSTALL\_FAILED\_NEWER\_SDK | equipment system version higher than the application requirements | |
| INSTALL\_FAILED\_TEST\_ONLY | test-only applications, but when you install `-t` parameter is not specified | |
| INSTALL\_FAILED\_TEST\_ONLY | test-only applications, but when you install `-t` parameter is not specified | |
| INSTALL\_FAILED\_CPU\_ABI\_INCOMPATIBLE | contains incompatible device CPU Application Binary Interface for native code | |
| INSTALL\_FAILED\_CPU\_ABI\_INCOMPATIBLE | contains incompatible device CPU Application Binary Interface for native code | |
| INSTALL\_FAILED\_MISSING\_FEATURE | application uses device features that are unavailable | |
| INSTALL\_FAILED\_MISSING\_FEATURE | application uses device features that are unavailable | |
| INSTALL\_FAILED\_CONTAINER\_ERROR | sdcard access failure | confirm sdcard is available, or to install built-in storage |
| INSTALL\_FAILED\_CONTAINER\_ERROR | sdcard access failure | confirm sdcard is available, or to install built-in storage |
| INSTALL\_FAILED\_INVALID\_INSTALL\_LOCATION | can not be installed to the specified location | switch mounting position, add or delete `-s` parameters |
| INSTALL\_FAILED\_INVALID\_INSTALL\_LOCATION | can not be installed to the specified location | switch mounting position, add or delete `-s` parameters |
| INSTALL\_FAILED\_MEDIA\_UNAVAILABLE | installation location is unavailable | generally sdcard, confirm sdcard is available or to install built-in storage |
| INSTALL\_FAILED\_MEDIA\_UNAVAILABLE | installation location is unavailable | generally sdcard, confirm sdcard is available or to install built-in storage |
| INSTALL\_FAILED\_VERIFICATION\_FAILURE | verify the installation package fails | |
| INSTALL\_FAILED\_VERIFICATION\_FAILURE | verify the installation package fails | |
| INSTALL\_FAILED\_PACKAGE\_CHANGED | calling application program expects inconsistent | |
| INSTALL\_FAILED\_PACKAGE\_CHANGED | calling application program expects inconsistent | |
| INSTALL\_FAILED\_UID\_CHANGED | previously installed the app, and this assignment UID inconsistent | remove residual files previously installed |
| INSTALL\_FAILED\_UID\_CHANGED | previously installed the app, and this assignment UID inconsistent | remove residual files previously installed |
| INSTALL\_FAILED\_VERSION\_DOWNGRADE | already installed the application later | use `-d` parameters |
| INSTALL\_FAILED\_VERSION\_DOWNGRADE | already installed the application later | use `-d` parameters |
| INSTALL\_FAILED\_PERMISSION\_MODEL\_DOWNGRADE | installed target SDK runtime support for application permissions of the same name, to install the runtime version does not support permission | |
| INSTALL\_FAILED\_PERMISSION\_MODEL\_DOWNGRADE | installed target SDK runtime support for application permissions of the same name, to install the runtime version does not support permission | |
| INSTALL\_PARSE\_FAILED\_NOT\_APK | specified path is not a file or not to `.apk` end | |
| INSTALL\_PARSE\_FAILED\_NOT\_APK | specified path is not a file or not to `.apk` end | |
| INSTALL\_PARSE\_FAILED\_UNEXPECTED\_EXCEPTION | parser encounters an exception | |
| INSTALL\_PARSE\_FAILED\_UNEXPECTED\_EXCEPTION | parser encounters an exception | |
| INSTALL\_PARSE\_FAILED\_NO\_CERTIFICATES | installation package is not signed | |
| INSTALL\_PARSE\_FAILED\_NO\_CERTIFICATES | installation package is not signed | |
| INSTALL\_PARSE\_FAILED\_INCONSISTENT\_CERTIFICATES | already installed the app, and signed with the APK files are inconsistent | first uninstall the application on the device, then install |
| INSTALL\_PARSE\_FAILED\_INCONSISTENT\_CERTIFICATES | already installed the app, and signed with the APK files are inconsistent | first uninstall the application on the device, then install |
| INSTALL\_PARSE\_FAILED\_MANIFEST\_EMPTY | in the manifest file can not be found to find operable label (instrumentation or application) | |
| INSTALL\_PARSE\_FAILED\_MANIFEST\_EMPTY | in the manifest file can not be found to find operable label (instrumentation or application) | |
| INSTALL\_FAILED\_INTERNAL\_ERROR | installation fails because of system problems | |
| INSTALL\_FAILED\_INTERNAL\_ERROR | installation fails because of system problems | |
| INSTALL\_FAILED\_USER\_RESTRICTED | Users are limited to installing applications | |
| INSTALL\_FAILED\_USER\_RESTRICTED | Users are limited to installing applications | |
| INSTALL\_FAILED\_DUPLICATE\_PERMISSION | application attempts to define an existing permission name | |
| INSTALL\_FAILED\_DUPLICATE\_PERMISSION | application attempts to define an existing permission name | |
| INSTALL\_FAILED\_NO\_MATCHING\_ABIS | applications include device application binary interface does not support the native code | |
| INSTALL\_FAILED\_NO\_MATCHING\_ABIS | applications include device application binary interface does not support the native code | |
| INSTALL\_CANCELED\_BY\_USER | applications installed on the device needs confirmation, but not operate the device or the point of cancellation | agree to install on the device |
| INSTALL\_CANCELED\_BY\_USER | applications installed on the device needs confirmation, but not operate the device or the point of cancellation | agree to install on the device |
| INSTALL\_FAILED\_ACWF\_INCOMPATIBLE | applications are not compatible with the device | |
| INSTALL\_FAILED\_ACWF\_INCOMPATIBLE | applications are not compatible with the device | |
| Does not contain AndroidManifest.xml | invalid APK file | |
| Does not contain AndroidManifest.xml | invalid APK file | |
| Is not a valid zip file | invalid APK file | |
| Is not a valid zip file | invalid APK file | |
| Offline | device is not connected successfully | first device with adb successful connection |
| Offline | device is not connected successfully | first device with adb successful connection |
| `-a <ACTION>` | specified action, such as `android.intent.action.VIEW` |
| `-a <ACTION>`| specified action, such as `android.intent.action.VIEW` |
| `-c <CATEGORY>` | specify a category, such as `android.intent.category.APP_CONTACTS` |
| `-c <CATEGORY>`| specify a category, such as `android.intent.category.APP_CONTACTS` |
| `-n <COMPONENT>` | specify the full component name, which is used to explicitly specify the start Activity, such as `com.example.app / .ExampleActivity` |
| `-n <COMPONENT>` | specify the full component name, which is used to explicitly specify the start Activity, such as `com.example.app / .ExampleActivity` |
`<INTENT>` can bring in data, like Bundle write code like:
`<INTENT>` can bring in data, like Bundle write code like:
@ -721,30 +691,30 @@ Such usage is very practical in the test, such as a broadcast scenes difficult t
Both predefined broadcast transmission system can also send a custom broadcast. The following is part of the normal pre-defined radio and Trigger timing:
Both predefined broadcast transmission system can also send a custom broadcast. The following is part of the normal pre-defined radio and Trigger timing:
| android.intent.action.MEDIA_UNMOUNTED | unload external media |
| android.intent.action.MEDIA_UNMOUNTED | unload external media |
| android.intent.action.MEDIA_MOUNTED | mount external media |
| android.intent.action.MEDIA_MOUNTED | mount external media |
| android.os.action.POWER_SAVE_MODE_CHANGED | power-saving mode is turned on |
| android.os.action.POWER_SAVE_MODE_CHANGED | power-saving mode is turned on |
* (Above broadcast can be used to trigger adb) *
* (Above broadcast can be used to trigger adb) *
@ -833,39 +803,39 @@ The commands and default sources are:
Such as using `adb shell input keyevent <keycode>` command, different keycode to achieve different functions, keycode complete list see [KeyEvent] (https://developer.android.com/reference/android/view/KeyEvent. html), I think the interesting part of the quote is as follows:
Such as using `adb shell input keyevent <keycode>` command, different keycode to achieve different functions, keycode complete list see [KeyEvent] (https://developer.android.com/reference/android/view/KeyEvent. html), I think the interesting part of the quote is as follows:
| 27 | taking pictures (in the camera application needs in) |
| 27 | taking pictures (in the camera application needs in) |
| 64 | Open Browser |
| 64 | Open Browser |
| 82 | menu button |
| 82 | menu button |
| 85 | Play / Pause |
| 85 | Play / Pause |
| 86 | stop playing |
| 86 | stop playing |
| 87 | play the next |
| 87 | play the next |
| 88 | played on a |
| 88 | played on a |
| 122 | Move the cursor to the beginning or top of the list |
| 122 | Move the cursor to the beginning or top of the list |
| 123 | Move the cursor to the end of the line or bottom of the list |
| 123 | Move the cursor to the end of the line or bottom of the list |
| 126 | resume playing |
| 126 | resume playing |
| 127 | pause play |
| 127 | pause play |
| 164 | Mute |
| 164 | Mute |
| 176 | Open the System Setup |
| 176 | Open the System Setup |
| 187 | switching applications |
| 187 | switching applications |
| 207 | Open Contacts |
| 207 | Open Contacts |
| 208 | Open calendar |
| 208 | Open calendar |
| 209 | Open Music |
| 209 | Open Music |
| 210 | Open Calculator |
| 210 | Open Calculator |
| 220 | Decrease screen brightness |
| 220 | Decrease screen brightness |
| 221 | Increase screen brightness |
| 221 | Increase screen brightness |
| 223 | System Sleep |
| 223 | System Sleep |
| 224 | light up the screen |
| 224 | light up the screen |
| 231 | Open the voice assistant |
| 231 | Open the voice assistant |
| 276 | If no wakelock allow the system to sleep |
| 276 | If no wakelock allow the system to sleep |
Here are some examples of the use of `input` command.
Here are some examples of the use of `input` command.
@ -1546,19 +1516,19 @@ This will output a lot of information, including the previously mentioned severa
In output also includes some other useful information, they can also be `adb shell getprop <attribute name>` command alone, part of the property include the following:
In output also includes some other useful information, they can also be `adb shell getprop <attribute name>` command alone, part of the property include the following:
| -d Display-id | screenshots display the specified number (multiple screen display case next) |
| -d Display-id | screenshots display the specified number (multiple screen display case next) |
Found If you specify a file name can be omitted when the -p parameter to `.png` ending; otherwise you need to use the -p parameter. If you do not specify a file name, file contents screenshot will be directly output to stdout.
Found If you specify a file name can be omitted when the -p parameter to `.png` ending; otherwise you need to use the -p parameter. If you do not specify a file name, file contents screenshot will be directly output to stdout.