Skip to content

Instantly share code, notes, and snippets.

@rabross
Last active April 24, 2024 10:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabross/2b8daaa696e44e8be4d882d8667a9614 to your computer and use it in GitHub Desktop.
Save rabross/2b8daaa696e44e8be4d882d8667a9614 to your computer and use it in GitHub Desktop.
ADB Cheatsheet

ADB Cheatsheet

adb commands

Command Description
adb devices Lists connected devices by serial
adb devices -l For more information
adb start-server Starts the adb server
adb kill-server Kills the adb server
adb reboot Reboots the device
adb install <filename> Installs an apk
adb uninstall <packagename> Uninstalls an apk
adb -s <device id> <command> Command runs on the specified device
adb -s <emulator id> emu kill Kills the specified emulator
adb logcat Starts printing log messages
adb logcat -c Clears the log buffers
adb logcat -f <filename> Dumps to specified file
adb wait-for-device <command> command will run once the device is connected
adb shell <shell command> run shell commands (see below)

adb shell commands

Enter a remote shell with the command adb shell, then run commands within

Or issue commands directly via adb without entering a remote shell adb shell <command>

Command Description
adb shell pm list packages -3 Lists all installed 3rd-party packages
adb shell pm clear <packagename> Clears cache and closes app
adb shell am start -a android.intent.action.VIEW -d <url> Can be used to test deeplinks
adb shell monkey -p <packagename> --throttle <event-delay> <event-count> To run UI exerciser monkey tool
adb shell dumpsys battery set level <number> sets device battery level
adb shell dumpsys battery reset reset device battery info
adb shell settings put system show_touches 1 Show taps (System turns them off during screenrecording)
adb shell input keyevent 4 Trigger a back button press
adb shell setprop debug.layout true Show layout bounds

Demo mode

Allows you to change the status bar for consistent sreenshots

Command Description
adb shell settings put global sysui_demo_allowed 1 enable demo mode
adb shell am broadcast -a com.android.systemui.demo -e command enter enter demo mode
adb shell am broadcast -a com.android.systemui.demo -e command exit exit demo mode
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm <time> set the clock
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false hide notification icons

Other

Command Description
ps -x | grep adb Find the adb process id (pid) then kill with the following command
kill -9 <pid> Kill the given process
killall adb Kill the given process

Sources

https://developer.android.com/studio/command-line/adb https://android.googlesource.com/platform/frameworks/base/+/master/packages/SystemUI/docs/demo_mode.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment