ADB Survival Guide for Android

List connected device(s)

First thing to do is to list connected device(s) by launching following command :

Upload a specified file on device

To move a file from your computer to a running Android device via the command line, adb offers you the push command that must be used like that :

Download a specified file from your device

As push adb command works to upload a specified file, pull adb command must be used to download a specified file from your device to your computer :

Apply command to a specific device

In our example, just one Android device is connected. But, in some cases, if you have several connected devices, you could define the device that you want to use to execute the adb command. Enter the following command :

Reboot a device

You can even reboot a device directly from the command line like that :

Reboot a device to the bootloader

Even better, you can also reboot a device to the bootloader :

Install an application

Once you have generated an application APK, you can install this on the Android device of your choice thanks to the install adb command. Note that you can use the optional -r argument to reinstall and kept any data if application is already installed on the device.

Uninstall an application

To uninstall an application, you must use the uninstall adb command like that :

Start an activity

To start an activity, you must use the shell adb command that lets you to execute specific command on the device. Imagine that you want start main activity of the application com.ssaurel.myapplication. You must enter following command line :

Entering in device’s shell

To execute specific commands on your device, you can use adh shell followed by the command name and wait for the result. Second solution, that you should use if you have several commands to execute, is to enter directly in device’s shell with that command :

Take a screenshot

Another great feature offered by adb is that it’s able to take screenshot of your device’s display. Great to automate screenshots via scripts. To take a simple screenshot, execute following command :

Record device display

Even better, since Android KitKat 4.4 you can record device display. Great to make demo video of an application for example. To achieve that, you must use screenrecord adb shell command. It accepts a lot of options like possibility to define a specific size, a bitrate or a time limit (default value is 120 seconds).

Power button

You can also emulate input on your device. For example, you can thus emulate power button event to turn the device on or off like that:

Unlock screen

With previous command, you can then unlock screen when you know keyevent number :

List installed packages

Other possibility is to list all installed packages on a device :

Logging

To know what your device is making, you can print log data to the screen :

Dump system data

To analyze some speficic problems, you can dump system data. Directly on the screen or in a defined file. To dump on the screen, enter following command line :

Execute classic Linux / Unix commands

As Android is based on Linux system, you can also take profit to execute classic commands like ls, cat, etc … Thus, you can get CPU info by displaying content of /proc/cpuinfo :

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store