Here are some useful commands I found for Android ADB. Automatic build and test processes can be manually or using.
View the device
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.
adb install -r APK_FILE
#example
adb install -r
Uninstall an app
adb uninstall APK_FILE
#example
adb uninstall
Start a page
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
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
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' >
Unscreen
This command will send a descreen event to the locked device
adb shell input keyevent 82
log
Log on the command line
adb logcat
Filter by tagname
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.
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
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
adb logcat -c