Android ADB Common CommandsThe crime of universal Origin2016.09.21 00:02* words 605 Read 2912 comments 0 likes 1
[TOC]
ADB logcat viewing logs
Detailed information can be found in
ADB Usage complete/adb Usage Daquan
Official documentation Listing of Logcat Command Options
Others integrate http://jiongbull.com/2016/03/17/adb%E5%91%BD%E4%BB%A4/
App-related view app list
list package# has rootadb shell ls /data/data/
ADB Start/Stop application
adb shell am start -n [packageName/StartActivity]adb shell am force-stop [packageName]
Port mappings
# Show All (pc-> DEVICE) mapped port connection list adb forward- List# Map port connection (pc-> DEVICE) adb forward (local) (remote) ADB Forward tcp:6100 tcp:7100# map port connection, but if local is already mapped it will fail adb forward-no-rebind (local" (remote) adb forward--no-rebind tcp:6100 tcp:7100# remove the specified mapping port connection adb Forward-remove tcp:6100# Remove all mapped ports connect adb forward-remove-all
# 显示所有来自设备的(DEVICE —> PC)映射的端口连接列表adb reverse —list# 反向映射端口连接(DEVICE —> PC)adb reverse (remote) (local)adb reverse tcp:7000 tcp:5000# 如果local已经映射了就会失败adb reverse —no-rebind (remote) (local)adb reverse --no-rebind tcp:7000 tcp:5000# 移除指定的反向映射端口连接adb reverse —remove tcp:7000adb reverse —remove-all
Application safety Loading and unloading
# 获取apk的packagename 和 classnameaapt d badging <apkfile># 安装apkadb install <apkfile># 保留数据和缓存文件,重新安装apk,adb install -r <apkfile># 安装apk到sd卡adb install -s <apkfile># 卸载appadb uninstall <package># 卸载app但保留数据和缓存文件adb uninstall -k <package># 同时安装包多个apk到设备上adb install-multiple
ADB Install parameters
-l
Lock Apps
-r
Replace an existing app
-t
Allow installation of test packages
-s
Install to SD card
-d
You can install the lower version of the installation package
-p
Installing some applications
-g
Authorizing all run-time permissions
App Status View
# 查看进程列表adb shell ps# 查看指定进程状态adb shell ps -x [PID]# 查看后台services信息adb shell service list# 查看IO内存分区adb shell cat /proc/iomem
Debug view
List all process numbers that have the JDWP port process
adb jdwp
File operations
# View all storage device names adb shell ls mnt# copy files locally to device adb Push <local> <remote># copy files from device to local ADB pull < remote> <local># lists files and folders in the directory, equivalent to the dir command in DOS ADB Shell Ls# into the folder, equivalent to Dos in the CD command adb shell CD <folder># rename file adb shell rename path/oldfilename path/newfilename# Delete system/ AVI.APKADB Shell Rm/system/avi.apk# Delete folder and all files below adb shell rm-r <folder># Mobile file adb shell mv Path/file newpath/file# set file permissions adb shell chmod 777 [FilePath ]# new folder adb shell mkdir-d path/foldelname
ADB sync
Synchronize content on Android devices /system
and directories that are /data
inconsistent with the host directory on the host.
Environment variables that require the host directory address to be set before use.
ADB sync (environment variable not set)
not specified; use -p or define ANDROID_PRODUCT_OUT
Set android_product_out = (PATH)
D:\Code\Git>set ANDROID_PRODUCT_OUT = D:\Data\Android
ADB sync (environment variable set)
/system/app/WAPPushManager.apk
Text manipulation
# 查看文件内容adb shell cat <file># 查看文件的头10行adb shell head -n 10 <file># 查看文件的尾10行adb shell tail -n 10 <file>
Root Permission action
- This operation requires a mobile phone after root to perform
# 尝试开启root权限,adb连接会重置 成功会提示 restarting adbd as rootadb root# 关闭root权限adb unroot# 重新挂载系统分区,使系统分区重新可写 成功提示 remount succeededadb remount# 重启设备,进入recovery程序的sideload模式,需要root权限adb reboot sideload
This allows you to manipulate the Android system files
dm-verity Check in debug environment
Unlock the system partition with this
disable-verity启用在调试环境下的dm-verity检查adb enable-verity
System Project Device Information
# 完整设备信息adb shell cat /system/build.prop# 厂商信息adb shell cat /system/build.prop | grep ro.product
Environment variables
ADB_TRACE Specifies the print debugging information, which can be set to the values in the following list, separated by commas
ADB, sockets, packets, RWX, USB, Sync, sysdeps, transport, and JDWP
Android_serial
Specifies the device to connect to, which -s
does not work if it is specified by
Android_log_tags
With Logcat, only debug information for these labels will be printed
Dumpsys
adb shell dumpsys wifiadb shell dumpsys cpuinfo
The contents of the current run of the dump can include
numbering |
Parameters |
1 |
Surfaceflinger |
2 |
Accessibility |
3 |
Account |
4 |
Activity |
5 |
Alarm |
6 |
Appwidget |
7 |
Audio |
8 |
Backup |
9 |
Battery |
10 |
Batteryinfo |
11 |
Bluetooth |
12 |
Bluetooth_a2dp |
13 |
Clipboard |
14 |
Connectivity |
15 |
Content |
16 |
Cpuinfo |
17 |
Device_policy |
18 |
Devicestoragemonitor |
19 |
Diskstats |
20 |
Dropbox |
21st |
Entropy |
22 |
Ethernet |
23 |
Hardware |
24 |
Input_method |
25 |
Iphonesubinfo |
26 |
Isms |
27 |
Keybar |
28 |
Location |
29 |
Media.audio_flinger |
30 |
Media.audio_policy |
31 |
Media.camera |
32 |
Media.player |
33 |
Meminfo |
34 |
Mount |
35 |
Netsta |
Device information
# 查看设备cpu和内存占用情况adb shell top# 查看占用内存前6的appadb shell top -m 6# 刷新一次内存信息,然后返回adb shell top -n 1# MAC地址adb shell cat /sys/class/net/wlan0/address# CPU序列号adb shell cat /proc/cpuinfo
Backup
# 把设备的数据归档写入文件中adb backupadb backup -f backup.ab -all
-f
Without this identity, the data will be written to the Backup.ab file in the current directory
-apk|-noapk
Enable | disable backup. apk file yourself, default is noapk
-obb|-noobb
Enable | Disable Backup app associated APK extension, default is Noobb
-shared|-noshared
Enable | Disables the contents of the backup device shared storage/sd, default is noshared
-all
Back up all installed apps
-system|-nosystem
Determines whether-all contains system applications, which by default include system applications
packages...
The list of apps that will be backed up, and if the-all or-shared ID is set, then this parameter will be optional
Recover device content from archived backup files
adb restoreadb restore backup.ab
Device operation
# 返回所有应该包含在错误报告中的设备信息adb bugreport# 重启adb reboot# 重启刷机模式adb reboot bootloader# 重启到恢复模式adb reboot recovery
A little gift to walk around, to Jane book Follow me
Android? Copyright belongs to the author all report the article Pan original crime
Wrote 56743 words, was paid attention by 178 people, gained 301 likes
Nothing is a line of code that cannot be resolved if there is a two-line Context Https://github.com/sinlov https://www.jianshu.com/p/37af717761cc
Android ADB Common Commands