Foreword
Android ADB's developing and debugging tool use. ADB (Android Debug Bridge) is a tool in the Android SDK, ADB directly using the operation management Andriod Android emulator or real device.
ADB main functions:
1, running on Android Shell (command line)
2, or emulator port mapping management device
3, between the computer and the device file upload / download
4, APK local software on the computer to install or Android emulator device
This chapter describes only some of my commonly used commands, there are some instructions not used, I did not understand or do not introduce, some instructions simply stated role, specific details can go online to check the use of the specific use, such as adb logcat adb shell dumpsys instructions and usage details many, not specific description, it could be slowly completion.
display screen
A display device connected to the current computer
List of devices attached
4b5df8f1 device
59a85475 device
Multiple devices
If multiple devices are connected to a computer, using the -s
selected set of instruction execution.
adb -s 4b5df8f1 install test.apk // 向id为4b5df8f1的设备安装test应用
Related instructions installation package installer, instruction format, adb install [option] <app_path >
adb install test.apk
adb install -r test.apk // 覆盖安装
卸载程序,指令格式,adb uninstall [options] <PACKAGE_NAME>
adb uninstall com.test.app // 卸载包名为com.test.app的程序
adb uninstall -k com.test.app // 卸载包名为com.test.app的程序,但是保留数据
列出设备中已安装的程序,adb shell pm list packages [options] <Filter_name>
See id for the 4b5df8f1
third-party installer of equipment, filtration word for baidu, example:
> adb -s 4b5df8f1 shell pm list packages -3 baidu
package:com.baidu.lbs.waimai
package:com.baidu.netdisk
adb shell pm list packages // 列出设备中所有已安装程序
adb shell pm list packages -d // 列出设备中无用程序,目前不知道有什么用
adb shell pm list packages -e // 列出设备中可用程序
adb shell pm list packages -s // 列出系统程序
adb shell pm list packages -3 // 列出第三方程序
adb shell pm list packages -i // 列出所有程序,并显示安装来源
adb shell pm list packages -u // 列出所有程序,包括已卸载程序
View installer apk file directory: adb shell pm path <PACKAGE>
The id of 4b5df8f1
the device in view package called com.baidu.netdisk
program installation package path location, examples:
Clear Cache: adb shell pm clear <PACKAGE>
示例:
> adb shell pm clear com.baidu.netdisk
Success
Documents related instructions
local_path may be a relative path, the path may be relatively
Copy the files from the device , adb pull <remote_path> <local_path>
// 将设备中/sdcard/demo.mp4拷贝到本机的e盘根目录
adb pull /sdcard/demo.mp4 e:\
Local files are copied to the device ,adb push <local_path> <remote_patch>
// d disk test.apk local file copy to the device / sdcard directory
adb push d:\test.apk /sdcard
The system access device , , adb shell
the Android device underlying Linux kernel, and Linux many instructions are the same kind of instructions, the following are some. Used adb shell
after the instruction enters the apparatus system, the following commands.
ls // 列出当前目录下面的文件
ls -a // 列出当前目录下的所有文件,包括隐藏文件
ls -l // 列出文件,包括文件的读写权限和组关系
cd <文件夹名称> // 进入某个文件夹
rm <文件名> // 删除某个文件
rm -f <文件名> // 强制删除某个文件
rm -r <文件夹> // 删除某个非空文件夹
rm -d <文件夹> // 删除文件夹,包括空文件夹,等同于rmdir指令
mkdir <文件名/文件夹名> // 创建文件或者文件夹
mkdir -m 777 <文件名/文件夹名> // 创建相应权限的文件夹,777是一种权限的代称
mkdir -p <文件名/文件夹名> // 如果不存在该文件或者文件夹,就创建
touch <文件名> // 新建文件
pwd // 打印当前目录
cp [options] <source_path> <dest_path> // 拷贝文件或者文件夹
move [options] <source_path> <dest_path> // 移动文件或者重命名文件
Log command
Output log adb logcat [option] [filter-specs]
, this view may be used in particular, the point where the individual common instruction format.
// 以单个关键字过滤日志,日志显示时间戳
adb logcat -v time | grep 关键字
adb logcat -v time | grep "关键字"
// 以多个关键字过滤日志,日志显示时间戳
adb logcat -v time | grep "关键字一\|关键字二"
Output information phone:
adb shell dumpsys [options],
// 查看电池使用情况
adb shell dumpsys battery
There are more ways to use official documents, for example, use it to view memory usage,
adb shell dumpstate
View all types of information, such as process information and memory information, the process is abnormal, kernnel the log, and some mobile phones NA, suggesting that the script did not find sh, OAO, ah, system customized results. View Current Activity:
// linux
adb shell dumpsys activity | grep "mFocusedActivity"
//windows
adb shell dumpsys activity | findstr "mFocusedActivity
Screenshots , interception of the current phone screen, adb shell screencap <filename>
and then you can re-use adb pull
instructions to copy pictures to a local
// 截取当前屏幕,图片保存到/sdcard目录下,名称为screen.png
adb shell screencap /sdcard/screen.png
Video recording , video recording screen operation, adb shell screenrecord [options] <filename>
, press ctrl + c to stop recording , the directive applies only to version 4.4 and above systems.
// 录取屏幕操作视频,保存到/sdcard目录下,名称为demo.mp4
adb shell screenrecord /sdcard/demo.mp4
// 录取视频,并设置录取视频的长宽
adb shell screenrecord --size <WIDTHxHEIGHT> <filename>
// 录取视频,设置最长录取时间
adb shell screenrecord --time-limit <TIME> <filename>
// 录取视频,角度旋转90度
adb shell screenrecord --rotate <filename>