adb uninstall com.test.app
adb uninstall -k com.test.app Keep the data and cache directories around after package removal.
包
打印所有包,可选择仅打印包名包含<FILTER>文本的包。
adb shell pm list packages [options] <FILTER-STR>
adb shell pm list packages <FILTER-STR>
adb shell pm list packages -f <FILTER-STR> #See their associated file.
adb shell pm list packages -d <FILTER-STR> #Filter to only show disabled packages.
adb shell pm list packages -e <FILTER-STR> #Filter to only show enabled packages.
adb shell pm list packages -s <FILTER-STR> #Filter to only show system packages.
adb shell pm list packages -3 <FILTER-STR> #Filter to only show third party packages.
adb shell pm list packages -i <FILTER-STR> #See the installer for the packages.
adb shell pm list packages -u <FILTER-STR> #Also include uninstalled packages.
adb shell pm list packages --user <USER_ID> <FILTER-STR> #The user space to query.
adb shell pm path <PACKAGE>
打印给定应用的 APK 路径。
adb shell pm path com.android.phone
adb shell pm clear <PACKAGE>
删除与一个应用程序相关的所有数据。
adb shell pm clear com.test.abc
文件管理器
adb pull <remote> [local]
从模拟器/设备下载指定文件到您的计算机。
adb pull /sdcard/demo.mp4 ./
adb push <local> <remote>
从您的计算机上传指定文件到模拟器/设备。
adb push test.apk /sdcard
屏幕截图/录屏
adb shell screencap <文件名>
对设备显示屏进行截图。
adb shell screencap /sdcard/screen.png
adb shell screenrecord [options] <filename>
记录运行Android 4.4(API级别19)及更高版本的设备显示。
adb shell screenrecord /sdcard/demo.mp4
adb shell screenrecord --size <WIDTHxHEIGHT>
adb shell screenrecord --bit-rate <RATE>
adb shell screenrecord --time-limit <TIME> #Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
adb shell screenrecord --rotate # Rotates 90 degrees
adb shell screenrecord --verbose
(press Ctrl-C to stop recording)
您可以使用 _adb pull_ 下载文件(图像和视频)
Shell
adb shell
在设备内部获取一个 shell
adb shell
adb shell <CMD>
在设备内部执行命令
adb shell ls
pm
以下命令在shell内执行
pm list packages #List installed packages
pm path <package name> #Get the path to the apk file of tha package
am start [<options>] #Start an activity. Whiout options you can see the help menu
am startservice [<options>] #Start a service. Whiout options you can see the help menu
am broadcast [<options>] #Send a broadcast. Whiout options you can see the help menu
input [text|keyevent] #Send keystrokes to device
adb logcat *:V # lowest priority, filter to only show Verbose level
adb logcat *:D # filter to only show Debug level
adb logcat *:I # filter to only show Info level
adb logcat *:W # filter to only show Warning level
adb logcat *:E # filter to only show Error level
adb logcat *:F # filter to only show Fatal level
adb logcat *:S # Silent, highest priority, on which nothing is ever printed
adb logcat -b <缓冲区>
adb logcat -b # radio View the buffer that contains radio/telephony related messages.
adb logcat -b # event View the buffer containing events-related messages.
adb logcat -b # main default
adb logcat -c # Clears the entire log and exits.
adb logcat -d # Dumps the log to the screen and exits.
adb logcat -f test.logs # Writes log message output to test.logs .
adb logcat -g # Prints the size of the specified log buffer and exits.
adb logcat -n <count> # Sets the maximum number of rotated logs to <count>.
adb shell dumpsys batterystats collects battery data from your device
注意:Battery Historian 将这些数据转换为 HTML 可视化。 步骤 1adb shell dumpsys batterystats > batterystats.txt步骤 2python historian.py batterystats.txt > batterystats.html
adb shell dumpsys batterystats --reset erases old collection data
adb shell dumpsys activity
# 备份
从adb备份安卓设备。
adb backup [-apk] [-shared] [-system] [-all] -f file.backup
# -apk -- Include APK from Third partie's applications
# -shared -- Include removable storage
# -system -- Include system Applciations
# -all -- Include all the applications
adb shell pm list packages -f -3 #List packages
adb backup -f myapp_backup.ab -apk com.myapp # backup on one device
adb restore myapp_backup.ab # restore to the same or any other device