Site Overlay

Android Debugger (ADB) cheat sheet

adb is the command-line tool used for interacting with Android devices and debugging Android apps via the terminal. It's an incredibly versatile tool, full of many hidden gems. It can let you debug your apps over WiFi, copy files to/from your device, view logs, run terminal commands, and much more.

Here's a quick list of some ADB commands that I found useful.


$ adb devices List of devices attached 1ABCD9GH4S9836 device

Get a list of connected devices

$ adb tcpip 5555 restarting in TCP mode port: 5555

Tell your device to start listening for incoming connections via WiFi, on port 5555

$ adb connect connected to

Connect to the device via WiFi. After this, you can now unplug it and continue debugging wirelessly.

$ adb disconnect disconnected everything

Disconnect all wifi connections. USB connections stay active, even though it says "everything".

Using the above commands, it's possible to create script to automatically start wireless debugging. Simply plug in your device, run the script, then unplug it again. You can find an example script for Mac (and maybe Linux) here. There's also one for Windows here.


$ adb shell ip -f inet addr show wlan0 7: wlan0: mtu 1500 qdisc mq state UP group default qlen 3000 inet brd scope global wlan0 valid_lft forever preferred_lft forever
$ adb shell "ip -f inet addr show wlan0 | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | head -1"

Get your device's WiFi IP address.

$ adb forward tcp:8080 tcp:8080 8080

Forward the port 8080 from your local machine to the localhost of the device. Very useful for debugging web apps locally.

Managing apps

$ adb install myapp.apk Performing Streamed Install Success

Install an APK from your computer onto the device.

$ adb uninstall Success

Uninstall an app by specifying it's package name.

$ adb shell pm list packages -3 ...

List installed apps. The -3 hides system apps.

$ adb shell pm clear Success

Clear all app data for the specified app.

$ adb shell am force-stop

Force quit an application.

$ adb shell monkey -p 1

Start an app's default activity. The 1 at the end is necessary.


$ adb shell ls /mnt/sdcard file1.jpg file2.txt ...

List files in the specified folder.

$ adb pull /mnt/sdcard/file1.jpg 1 file pulled, 0 skipped. 1.2 MB/s (5779 bytes in 0.005s)

Pull a file from the device. You can also specify a destination directory or file name on your computer as an extra argument.

$ adb push file1.jpg /mnt/sdcard 1 file pushed, 0 skipped. 0.4 MB/s (10414 bytes in 0.027s)

Push a file to the device. First argument is the path on your computer, the second is the path on the device.


$ adb logcat

Display all logs from every app. See here for logcat arguments.

$ adb logcat -e MyTag

Filter log output to only lines that match the specified search query. Regex supported.

Other useful commands

$ adb shell screencap /mnt/sdcard/screenshot.png $ adb pull /mnt/sdcard/screenshot.png

Take a screenshot and save it to your computer.

$ adb shell screenrecord /mnt/sdcard/video.mp4 $ adb pull /mnt/sdcard/video.mp4

Record your device's screen. Press Ctrl+C to stop the recording.