SoFunction
Updated on 2025-04-10

Some more practical Android adb commands shared

Here are some useful commands I found for Android ADB. Automatic build and test processes can be manually or using.

View the device

Copy the codeThe code is as follows:

adb devices

If multiple devices are connected, use adb -s DEVICE_ID to connect to the target device

Install the application

Use the install command to install an apk package. If the application has been installed on the device, use -r to reinstall and maintain the original application data.

Copy the codeThe code is as follows:

adb install -r APK_FILE

#example
adb install -r

Uninstall an app

Copy the codeThe code is as follows:

adb uninstall APK_FILE

#example
adb uninstall

Start a page

Copy the codeThe code is as follows:

adb shell am start PACKAGE_NAME/ACTIVITY_IN_PACKAGE
adb shell am start PACKAGE_NAME/FULLY_QUALIFIED_ACTIVITY

# example
adb shell am start -n /.MainActivity
adb shell am start -n /

Enter the device's shell interface

Copy the codeThe code is as follows:

adb shell

screenshot

Sergei ShvetsovI came up with a good way to get a screenshot and use shell screencap to output to a local directory via perl. Check it out in detailHis blogExplanation given

Copy the codeThe code is as follows:

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' >

Unscreen

This command will send a descreen event to the locked device

Copy the codeThe code is as follows:

adb shell input keyevent 82

log

Log on the command line

Copy the codeThe code is as follows:

adb logcat

Filter by tagname
Copy the codeThe code is as follows:

adb logcat -s TAG_NAME
adb logcat -s TAG_NAME_1 TAG_NAME_2

#example
adb logcat -s TEST
adb logcat -s TEST MYAPP

Priority filtering

Displays a specific priority warning and above log.

Copy the codeThe code is as follows:

adb logcat "*:PRIORITY"

# example
adb logcat "*:W"

Priority:

V — Rules (minimum priority)
D — Debugging
I — Information
W — Warning
E — Error
F — Fatal
S — Silence (highest priority, no information is printed)

Use grep to filter

This is very similar to using pipeline commands on Linux, and requires system support

Copy the codeThe code is as follows:

adb logcat | grep "SEARCH_TERM"
adb logcat | grep "SEARCH_TERM_1\|SEARCH_TERM_2"

#example
adb logcat | grep "Exception"
adb logcat | grep "Exception\|Error"


Clear log blocks

Use to clear old logs

Copy the codeThe code is as follows:

adb logcat -c