ADB Commands
Course Index
Index

ADB Commands Cheat Sheet

Basic Commands



To start server. adb start-server

To stop server. adb kill-server

To reboot server adb reboot

To open or run commands in a terminal on the host Android device. adb shell

To show devices attached. adb devices

To show devices attached with product/model adb devices -l

To pair the devices for debugging. adb pair ip_address_of_device:port

To connect the devices wirelessly adb connect ip_address_of_device:port

To get attached device android version adb shell getprop ro.build.version.release

Installing App



To install apk only to the running emulator adb -e install path/to/app.apk

To install apk only to the connected USB device adb -d install path/to/app.apk

To install apk only to the device with given serial number. adb -s install path/to/app.apk

To install apk only to the given product name or path adb -p install path/to/app.apk

To install the given app on all connected devices. adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb -s X install -r com.myAppPackage

Uninstalling App



To uninstall app from device using package name. adb uninstall com.myAppPackage

To uninstall app from device using apk name. adb uninstall [app.apk]

To uninstall app from device without deleting data. adb uninstall -k [app.apk]

To uninstall app by package name using shell. adb shell pm uninstall com.example.MyApp

To clear all the data of given app package. adb shell pm clear [package]

To uninstall the given app from all connected devices. adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb -s X uninstall com.myAppPackage

To re-install the app and keep its data on the device. adb install -r [yourApp.apk]

To install app from your computer. adb install –k [/path/to/app/myapp.apk]

Activity Manager



To make a call. adb shell am start -a android.intent.action.CALL -d tel:+1234567890

To send SMS by opening message screen with phone number and the message. adb shell am start -a android.intent.action.SENDTO -d sms:+1234567890 --es sms_body "Test Message --ez exit_on_sent false

To reset app permission. adb shell pm reset-permissions -p your.app.package

To grant a permission to an app. adb shell pm grant [packageName] [ Permission]

To revoke a permission from an app. adb shell pm revoke [packageName] [ Permission]

Key Event



To go to home screen adb shell input keyevent 3

To go back adb shell input keyevent 4

To make call adb shell input keyevent 5

To end call adb shell input keyevent 6

To turn Android device ON and OFF. adb shell input keyevent 26

To turn on camera adb shell input keyevent 27

To open default browser adb shell input keyevent 64

To press enter adb shell input keyevent 66

To press backspace adb shell input keyevent 67

To open contacts adb shell input keyevent 207

Device Information



To get serial number of the device. adb get-serialno

To get the battery status adb shell dumpsys battery

To get activity info adb shell dumpsys activity [package/activity]

To print current app's opened activity. dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

Package Info



To list installed package names adb shell list packages

To list package name and path to apks adb shell list packages -r

To list only third party app package names adb shell list packages -3

To list only system app package names adb shell list packages -s

To show information on all apps adb shell dumpsys package packages

To show information on given one packae. adb shell dump [name]

To get path to the apk file adb shell path [package]

Screen Capture & Recording



To take screenshot. adb shell screencap -p /sdcard/screenshot.png

To record screen. adb shell screenrecord /sdcard/NotAbleToLogin.mp4

Logs



To view the current logs on the device. adb logcat

To clear the current logs on the device. adb logcat -c

To save the logcat output to a file on the local system. adb logcat -d > [path_to_file]

To dump the whole device information like dumpstate, dumpsys and logcat output. adb bugreport > [path_to_file]

Copy Files



To copy files from your computer to your phone. adb push [source] [destination]

To copy files from your phone to your computer. adb pull [device file location] [local file location]