Useful adb Commands

Aug 31, 2023

adb is a tool communicate with a virtual or physical Android device. It can be also used to simulate user input. A few useful commands:

Input

Type text:

adb shell input text "Your%sText"

(%s means space)

Type a special key:

adb shell input keyevent $KEY_EVENT_CODE

(KEY_EVENT_CODEs are defined here)

Files

Upload a file to device:

adb push $LOCAL_FILE /sdcard/$TARGET_FILE

Install and Run Apps

Install app via APK:

adb install app/build/outputs/apk/debug/app-debug.apk

Start a specific activity:

adb shell am start -a android.intent.action.MAIN -n at.xa1.your.applicationid/at.xa1.your.LaunchActivity

Open a link:

adb shell am start -a android.intent.action.VIEW -d 'https://xa1.at'

(Useful for testing deeplinks)

Terminal

Change to root:

adb shell
su

Logcat

Print logcat live in terminal:

adb logcat

…with filter:

adb logcat | grep ">>>"

Clear on device:

adb logcat -c

You might also like