参考链接

常用命令

Prints a list of all attached emulator/device instances.

1
adb devices

Pushes an Android application (specified as a full path to an .apk file) to an emulator/device.

1
adb install <path-to-apk>

Copies a specified file from an emulator/device instance to your development computer.

1
adb pull <remote> <local>

Copies a specified file from your development computer to an emulator/device instance.

1
adb push <local> <remote>

Checks whether the adb server process is running and starts it, if not.

1
adb start-server

Terminates the adb server process.

1
adb kill-server

Starts a remote shell in the target emulator/device instance.

1
adb shell

Issues a shell command in the target emulator/device instance and then exits the remote shell.

1
adb shell [shellCommand]

列出所有包名

1
2
3
4
5
6
7
8
9
10
adb shell pm list packages

-f: See their associated file.
-d: Filter to only show disabled packages.
-e: Filter to only show enabled packages.
-s: Filter to only show system packages.
-3: Filter to only show third party packages.
-i: See the installer for the packages.
-u: Also include uninstalled packages.
--user <USER_ID>: The user space to query.

清除数据

1
adb shell pm clear <PACKAGE>

截图

1
adb shell screencap /sdcard/screen.png

录屏

1
2
3
4
5
6
7
8
9
adb shell screenrecord /sdcard/demo.mp4

--help Displays command syntax and options
--size <WIDTHxHEIGHT> Sets the video size: 1280x720. The default value is the device's native display resolution (if supported), 1280x720 if not. For best results, use a size supported by your device's Advanced Video Coding (AVC) encoder.
--bit-rate <RATE> Sets the video bit rate for the video, in megabits per second. The default value is 4Mbps. You can increase the bit rate to improve video quality, but doing so results in larger movie files. The following example sets the recording bit rate to 6Mbps:
screenrecord --bit-rate 6000000 /sdcard/demo.mp4
--time-limit <TIME> Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
--rotate Rotates the output 90 degrees. This feature is experimental.
--verbose Displays log information on the command-line screen. If you do not set this option, the utility does not display any information while running.

读取数据相关命令

1
run-as PACKAGE_NAME