adb Cheatsheet | Android Debug Bridge

ยท 529 words ยท 3 minute read

adb ๐Ÿ”—

Android Debug Bridge: communicate with an Android emulator instance or connected Android devices.

Check whether the adb server process is running and start it:

adb start-server

Terminate the adb server process:

adb kill-server

Start a remote shell in the target emulator/device instance:

adb shell

Push an Android application to an emulator/device to be installed:

adb install -r path/to/file.apk

Copy a file/directory from the target device:

adb pull path/to/device_file_or_directory path/to/local_destination_directory

Copy a file/directory to the target device:

adb push path/to/local_file_or_directory path/to/device_destination_directory

List all connected devices:

adb devices

adb shell ๐Ÿ”—

Here are some more about adb shell subcommand.

Get all the properties from emulator or device:

adb shell getprop

Revert all runtime permissions to their default for all installed apps:

adb shell pm reset-permissions

Revoke a dangerous permission for an application:

adb shell pm revoke package permission

Trigger a key event:

adb shell input keyevent keycode

Clear the data of an application on an emulator or device:

adb shell pm clear package

Start an activity on emulator or device:

adb shell am start -n package/activity

Start the home activity on an emulator or device:

adb shell am start -W -c android.intent.category.HOME -a android.intent.action.MAIN

adb install ๐Ÿ”—

Push an Android application to an emulator/device:

adb install path/to/file.apk

Push an Android application to a specific emulator/device (overrides $ANDROID_SERIAL):

adb -s serial_number install path/to/file.apk

[r]einstall an existing app, keeping its data:

adb install -r path/to/file.apk

Push an Android application allowing version code [d]owngrade (debuggable packages only):

adb install -d path/to/file.apk

[g]rant all permissions listed in the app manifest:

adb install -g path/to/file.apk

Quickly update an installed package by only updating the parts of the APK that changed:

adb install --fastdeploy path/to/file.apk

adb logcat ๐Ÿ”—

adb logcat : Dump a log of system messages.

Display system logs:

adb logcat

Display lines that match a regular [e]xpression:

adb logcat -e regular_expression

Display logs for a tag in a specific mode ([V]erbose, [D]ebug, [I]nfo, [W]arning, [E]rror, [F]atal, [S]ilent), filtering other tags:

adb logcat tag:mode *:S

Display logs for React Native applications in [V]erbose mode [S]ilencing other tags:

adb logcat ReactNative:V ReactNativeJS:V *:S

Display logs for all tags with priority level [W]arning and higher:

adb logcat *:W

Display logs for a specific PID:

adb logcat --pid=pid

Display logs for the process of a specific package:

adb logcat --pid=$(adb shell pidof -s package)

Color the log (usually use with filters):

adb logcat -v color

adb reverse ๐Ÿ”—

Android Debug Bridge Reverse: reverse socket connections from an Android emulator instance or connected Android devices.

List all reverse socket connections from emulators and devices:

adb reverse --list

Reverse a TCP port from an emulator or device to localhost:

adb reverse tcp:remote_port tcp:local_port

Remove a reverse socket connections from an emulator or device:

adb reverse --remove tcp:remote_port

Remove all reverse socket connections from all emulators and devices:

adb reverse --remove-all

For more information, check out the official documentation for adb and logcat .

I hope this post helps you. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .

Share:
waffarx cash back