标签:
由于本人学习Android也挺长时间了,一直把日记记在evernote里面,由于刚离职比较空闲就打算把evernote里的日志一遍遍整理出来发布到网上分享。
要在cmd命令中直接使用adb,需要配置环境变量:目录XXX\sdk\platform-tools
查看adb -help 帮助命令打印出以下内容:
Android Debug Bridge version 1.0.31 <!--安卓调试桥接器 版本号:1.0.31-->
-a - directs adb to listen on all interfaces for a connection
<!-- -a 参数,指示adb侦听连接的所有接口。 -->
-d - directs command to the only connected USB device
returns an error if more than one USB device is present.
<!-- -d 参数,指示命令仅连接USB设备
如果同时存在多个USB设备,将会返回一个错误。
-->
-e - directs command to the only running emulator.
returns an error if more than one emulator is running.
<!-- -e 参数,指示仅连接运行中的模拟器--
如果超过一个模拟器在运行,将返回一个错误。
-->
-s <specific device> - directs command to the device or emulator with the given
serial number or qualifier. Overrides ANDROID_SERIAL environment variable.
<!-- -s <specific device>(给定的设备) 参数,根据给定的序列号或修饰词<specific device>,命令指定到那个设备或者模拟器。
覆盖ANDROID_SERIAL环境变量。
-->
-p <product name or path> - simple product name like ‘sooner‘, or
a relative/absolute path to a product out directory like ‘out/target/product/sooner‘.
If -p is not specified, the ANDROID_PRODUCT_OUT environment variable is used,
which must be an absolute path.
<!-- -p <product name or path>(产品名称或路径) 参数,显示其产品的名称,如:"sooner",或者
是一个相对/绝对的产品输出路径,如:"out/target/product/sooner"。
如果-p没有指定的话,就会使用ANDROID_PRODUCT_OUT的环境变量,那必须是一个绝对路径。
-->
-H - Name of adb server host (default: localhost)
<!-- -H 参数,指示adb 服务主机名 -->
-P - Port of adb server (default: 5037)
<!-- -P 参数,指示adb 服务端口号 -->
devices [-l] - list all connected devices
(‘-l‘ will also list device qualifiers)
<!-- adb devices [-l]通过此命令可以列出所有已经连接的设备
添加‘-l‘参数将列出设备修饰语
eg: adb devices -l
List of devices attached
da0b232e device product:jflteuc model:GT_I9500 device:jflteatt
-->
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
<!-- adb connect <host>[:<port>]通过TCP/IP连接设备,如果没有指定端口号,使用默认5555端口。
-->
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devices.
<!-- adb disconnect [<host>[:<port>]]使用此命令可以去断开来自TCP/IP的设备连接,
如果没有指定端口号,使用默认5555端口。
使用这个命令不添加额外的参数将会断开所有TCP/IP连接的设备。
-->
device commands:
<!--设备命令-->
adb push [-p] <local> <remote>
- copy file/dir to device
(‘-p‘ to display the transfer progress)
<!--adb push [-p] <local> <remote>命令:复制一个文件/目录到设备中--
-p 参数指定,显示传输进度
-->
adb pull [-p] [-a] <remote> [<local>]
- copy file/dir from device
(‘-p‘ to display the transfer progress)
(‘-a‘ means copy timestamp and mode)
<!--adb pull [-p] [-a] <remote> [<local>]命令:从设备中复制一个文件/目录出来
-p 参数指定,显示传输进度
-a 指复制的时间戳和模式。
-->
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don‘t copy)
(see ‘adb help all‘)
<!--adb sync [ <directory> ]命令:复制主机内容到设备,仅在设备内容改变后对其内容进行同步处理操作。
-l 意味着列出但不复制
参考 adb help all 命令。
-->
adb shell - run remote shell interactively
<!--adb shell命令:与远程shell交互运行。
-->
adb shell <command> - run remote shell command
<!--adb shell <command>命令:运行远程shell命令
如:adb shell ls -l
-->
adb emu <command> - run emulator console command
<!--adb emu <command>命令:运行模拟器控制台命令
-->
adb logcat [ <filter-spec> ] - View device log
<!--adb logcat命令:查看设备日志
-->
adb forward --list - list all forward socket connections.
the format is a list of lines with the following format:
<serial> " " <local> " " <remote> "\n"
<!--adb forward --list命令:列出所有转发套接字连接。
这个的格式是一个行列表,格式如下:
<serial> " " <local> " " <remote> "\n"
-->
adb forward <local> <remote> - forward socket connections
forward specs are one of:
<!--adb forward <local> <remote> 命令用户转发PC指定的端口<local>到设备指定的端口<remote>。
转发socket连接的转发规格如下:-->
tcp:<port>
<!--tcp:<端口号>-->
localabstract:<unix domain socket name>
<!--localabstract:<unix 域套接字名称>-->
localreserved:<unix domain socket name>
<!--localreserved:<unix 域套接字名称>-->
localfilesystem:<unix domain socket name>
<!--localfilesystem:<unix 域套接字名称>-->
dev:<character device name>
<!--dev:<字符设备名称>-->
jdwp:<process pid> (remote only)
<!--jdwp:<远程进程编号>-->
<!--
注:
unix domain socket
参见:http://zh.wikipedia.org/wiki/Unix_domain_socket
jdwp
参见:http://zh.wikipedia.org/wiki/JPDA
1.eg:
adb forward tcp:6100 tcp:7100 // PC上所有6100端口通信数据将被重定向到手机端/模拟器7100端口server上
2.eg:
adb forward tcp:6100 local:logd // PC上所有6100端口通信数据将被重定向到手机端/模拟器UNIX类型socket上
-->
adb forward --no-rebind <local> <remote>
- same as ‘adb forward <local> <remote>‘ but fails
<!--
如果指定--no-rebind,相同的adb forward <local> <remote>命令 将失败。
-->
if <local> is already forwarded
<!--如果<local>已经转发-->
adb forward --remove <local> - remove a specific forward socket connection
<!--adb forward --remove <local> 移除一个指定的转发socket连接-->
adb forward --remove-all - remove all forward socket connections
<!--adb forward --remove-all 移除所有的转发socket连接-->
adb jdwp - list PIDs of processes hosting a JDWP transport
<!--adb jdwp 显示托管在一个jdwp传输的进程pid列表-->
adb install [-l] [-r] [-d] [-s] [--algo <algorithm name> --key <hex-encoded ke
y> --iv <hex-encoded iv>] <file>
- push this package file to the device and install it
(‘-l‘ means forward-lock the app)
(‘-r‘ means reinstall the app, keeping its data
)
(‘-d‘ means allow version code downgrade)
(‘-s‘ means install on SD card instead of internal storage)
(‘--algo‘, ‘--key‘, and ‘--iv‘ mean the file is encrypted already)
<!--
adb install [-l] [-r] [-d] [-s] [--algo <algorithm name> --key <hex-encoded ke
y> --iv <hex-encoded iv>] <file> 通过这个命令来将打包的APK包文件安装到设备中,
-l 表示锁定的APP,
-r 表示重新安装app,保留原来的数据,
-d 表示允许版本代码降级
-s 表示安装在SD卡,而不是内部存储
‘--algo‘, ‘--key‘, and ‘--iv‘ 表示文件已经加密
-->
adb uninstall [-k] <package> - remove this app package from the device
(‘-k‘ means keep the data and cache directories
)
<!--
adb uninstall [-k] <package> 命令,用来删除安装在设备上的APK包,
-k意味着保留数据和缓存目录
-->
adb bugreport - return all information from the device that should be included in a bug report.
<!--
adb bugreport 输出设备所有信息,包含在缺陷报告中。
-->
adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all]
[-system|-nosystem] [<packages...>]
- write an archive of the device‘s data to <file>.
If no -f option is supplied then the data is written to "backup.ab" in the current directory.
(-apk|-noapk enable/disable backup of the .apks themselves in the archive;
the default is noapk.)
(-obb|-noobb enable/disable backup of any installed apk expansion
(aka .obb) files associated with each application; the default is noobb.)
(-shared|-noshared enable/disable backup of the device‘s shared storage / SD card contents;
the default is noshared.)
(-all means to back up all installed applications)
(-system|-nosystem toggles whether -all automatically includes system applications;
the default is to include system apps)
(<packages...> is the list of applications to be backed up.
If the -all or -shared flags are passed, then the package list is optional.
Applications explicitly given on the command line will be included
even if -nosystem would ordinarily cause them to be omitted.)
<!--adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all]
[-system|-nosystem] [<packages...>]将设备的数据写入的一个归档文件<file>中(PC目录文件)。
如果没有提供-f选项,数据将写入到当前目录的backup.ab文件中。
-apk|-noapk 启用/禁用 备份自己的apk文件到归档文件中。默认禁用。
-obb|-noobb 启用/禁用 备份与每个应用程序关联的任何安装的apk扩展文件(又名.obb文件(opaque binary blobs))
-shared|-noshared 启用/禁用 设备共享存储/SD 卡内容备份。默认禁用。
-all 备份所有安装的应用。-all 默认自动包含系统应用。
-system|-nosystem 指定是否切换包含系统应用。默认为包含系统应用。
<packages...> 需要备份的应用程序列表
如果已经使用 -all 或 -shared 标记,那么包列表<packages...>是可选的。
应用程序显式的包含在命令行中,即使 -nosystem标记指定忽略系统应用。
-->
adb restore <file> - restore device contents from the <file> backup archive
<!--adb restore <file>通过备份的归档文件恢复设备内容-->
adb help - show this help message
<!--adb help显示adb帮助信息-->
adb version - show version num
<!--adb version显示adb版本号-->
scripting:
<!--脚本-->
adb wait-for-device - block until device is online
<!--adb wait-for-device 等待直到设备在线-->
adb start-server - ensure that there is a server running
<!--adb start-server 确保服务已经运行-->
adb kill-server - kill the server if it is running
<!--adb kill-server 杀死运行中的服务-->
adb get-state - prints: offline | bootloader | device
<!--adb get-state 打印设备的状态:offline | bootloader | device-->
adb get-serialno - prints: <serial-number>
<!--adb get-serialno 打印设备序列号信息-->
adb get-devpath - prints: <device-path>
<!--adb get-devpath 打印设备路径-->
adb status-window - continuously print device status for a specified device
<!--adb status-window 连续打印指定的设备状态-->
adb remount - remounts the /system partition on the device read-write
<!--adb remount 对其设备系统分区读写进行重新挂载-->
adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
<!--adb reboot 重启设备,可选进入引导程序或者恢复程序。 -->
adb reboot-bootloader - reboots the device into the bootloader
<!--adb reboot-bootloader 重启设备,进入引导程序(刷机模式)。 -->
adb root - restarts the adbd daemon with root permissions
<!--adb root重新启动adbd后台进程获得ROOT权限-->
adb usb - restarts the adbd daemon listening on USB
<!--adb usb重新启动adbd后台进程监听USB-->
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
<!--adb tcpip <port>重新启动adbd后台进程,来监听指定的TCP端口-->
networking:
<!--网络-->
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters]
- Eg. default route debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition is updated.
<!--
adb ppp <tty> [parameters] - 在USB上运行的PPP。
注意:你不能自动启动PPP连接。
<tty>指的tty为PPP流。例如。dev:/dev/omap_csmi_tty1[parameters]
- 例如。默认路由调试丢弃本地notty usepeerdns
adb sync notes: adb sync [ <目录> ]
<localdir> 可以有几种方式解释:
- 如果没有指定<directory><目录> /system 和 /data分区将被更新。
- 如果它是"system" 或 "data" ,只有对应的分区被更新。
-->
environmental variables:
<!--环境变量-->
ADB_TRACE - Print debug information.
A comma separated list of the following values 1 or all, adb, sockets, packets, rwx, usb, sync
, sysdeps, transport, jdwp
<!--
ADB_TRACE环境变量 -打印调试信息。使用逗号分隔,列出下列一个或者全部:adb, sockets, packets, rwx, usb, sync
, sysdeps, transport, jdwp
-->
ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.
<!--ANDROID_SERIAL - 连接到的序列号。 假如给定-s参数,它的优先级将高于这个环境变量。-->
ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.
<!--ANDROID_LOG_TAGS环境变量,-当使用logcat的选项,只有这些调试标签会被打印出来。-->
官方adb工具相关文档可以参见:
http://developer.android.com/tools/help/adb.html
作者:sufish
出处:http://www.cnblogs.com/dotnetframework/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以邮件:dotnetframework@sina.com联系我,非常感谢。
标签:
原文地址:http://www.cnblogs.com/dotnetframework/p/4475546.html