See full documentation here: https://developer.android.com/studio/command-line/adb
Check if you have any devices connected:
adb devicesIf more than one device is connected, you need to pass device serial to every adb command:
adb -s 12345678 install com.packageInstall an APK:
adb install /path/to/apk/com.pocketgeek.android-3.4.5-12345.apkUninstall a package:
adb uninstall com.package.namePrint all logs in terminal:
adb logcatFilter logs by priority level (D for 'debug', W for 'warning', E for 'error'):
adb logcat *:wNote: when you specify the level in filter, it will print that level and higher. E.g., 'w' will include 'warning' and 'error'. Priority levels here for reference.
Record logs to a file:
adb logcat > file.logPrint logs to terminal and record to file:
adb logcat | tee file.logFilter for crashes:
- Using logcat buffer:
crash:
adb logcat -b crash- Using native ADB tags:
adb logcat AndroidRuntime:E *:S- You can also
grepfor 'FATAL EXCEPTION' +xlines after:
adb logcat | grep FATAL -A 30List all installed packages:
adb shell pm list packagesOnly list 3rd party apps (exculde system apps):
adb shell pm list packages -3Filter by specific package name (using grep and pattern):
adb shell pm list packages | grep pocketgeekClear app data:
adb shell pm clear com.package.nameTo see current and/or default DPI:
adb shell wm densityChange the DPI to a desired value:
adb shell wm density 200Reset to deafault:
adb shell wm density resetYou can also change the screen size/resolution: replace 'density' with 'size' in the commands above.
To see current battery stats:
adb shell dumpsys batteryTo mock your battery level:
adb shell dumpsys set level <number b/w 1-100>To mock your battery status (charging ac, charging usb, charging wireless, not charging):
adb shell dumpsys set status 1/2/3/4See all battery status constants here
Alternative way to set status 'unplugged':
adb shell dumpsys battery unplugReset mocked battery state:
adb shell battery resetLaunch an app:
adb shell monkey -p com.package name 1