zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

adb命令大全

adb命令 大全
2023-09-14 08:59:10 时间

废话不多说,直接adb -help查看所有命令然后翻译

 -a                            - directs adb to listen on all interfaces for a connection

指导adb监听连接的所有接口。

 -d                            - directs command to the only connected USB device
                                 returns an error if more than one USB device is present.

引导命令到唯一连接的USB设备。如果存在多个USB设备,则返回一个错误。

 -e                            - directs command to the only running emulator.
                                 returns an error if more than one emulator is running.

将命令定向到唯一运行的模拟器。如果存在多个模拟设备,则返回一个错误。

 -s <specific device>          - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.

用给定的序列号或限定符将命令定向到设备或模拟器。覆盖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.

简单的产品名称如“早sooner”,或者一个相对/绝对路径等产品目录“out/target/product/sooner”。如果没有指定-p,则使用ANDROID_PRODUCT_OUT环境变量,这必须是一条绝对路径。

 -H                            - Name of adb server host (default: localhost)

adb服务器主机名称(默认:localhost)

 -P                            - Port of adb server (default: 5037)

adb服务器端口(默认:5037)

 devices [-l]                  - list all connected devices
                                 ('-l' will also list device qualifiers)

列出所有连接的设备。('-l'也会列出设备限定词)

 connect <host>[:<port>]       - connect to a device via TCP/IP
                                 Port 5555 is used by default if no port number is specified.

-通过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.

断开与TCP/IP设备的连接。

如果没有指定端口号,则默认使用端口5555。

使用此命令,不需要其他参数。

将断开所有连接的TCP/IP设备。

device commands:

  adb push <local>... <remote>
                               - copy files/dirs to device

拷贝文件/dirs到设备。

  adb pull [-a] <remote>... <local>
                               - copy files/dirs from device
                                 (-a preserves file timestamp and mode)

从设备复制文件/dirs。

(保存文件时间戳和模式)

  adb sync [ <directory> ]     - copy host->device only if changed
                                 (-l means list but don't copy)

复制主机->设备仅当更改。

(-l表示列表,但不要复制)

  adb shell [-e escape] [-n] [-Tt] [-x] [command]
                               - run remote shell command (interactive shell if no command given)
                                 (-e: choose escape character, or "none"; default '~')
                                 (-n: don't read from stdin)
                                 (-T: disable PTY allocation)
                                 (-t: force PTY allocation)
                                 (-x: disable remote exit codes and stdout/stderr separation)

运行远程shell命令(如果没有命令,则使用交互式shell)

(-e:选择escape字符,或“none”;默认的“~”)

(-n:不要读stdin)

(- t:禁用企业分配)

(- t:迫使企业分配)

(-x:禁用远程退出代码和stdout/stderr分离)

  adb emu <command>            - run emulator console command

运行模拟器控制台命令。

  adb logcat [ <filter-spec> ] - View device log

View设备日志。

 adb forward --list           - list all forward socket connections.
                                 the format is a list of lines with the following format:
                                    <serial> " " <local> " " <remote> "\n"

列举所有转发套接字连接。

格式是一列有下列格式的行:

<serial >  <local>  <remote> 

  adb forward <local> <remote> - forward socket connections
                                 forward specs are one of:
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
                                   dev:<character device name>
                                   jdwp:<process pid> (remote only)

转发套接字连接。

远期规格是:

tcp:<端口号>

localabstract:< unix域套接字名称>

localreserved:< unix域套接字名称>

localfilesystem:< unix域套接字名称>

dev:<字符设备名称>

jdwp:<过程pid >(仅远程)

  adb forward --no-rebind <local> <remote>
                               - same as 'adb forward <local> <remote>' but fails
                                 if <local> is already forwarded

与“adb forward <本地> <远程>”相同,但如果<本地>已被转发,则会失败。

  adb forward --remove <local> - remove a specific forward socket connection

删除一个特定的前向套接字连接。

  adb forward --remove-all     - remove all forward socket connections

删除所有转发套接字连接。

  adb reverse --list           - list all reverse socket connections from device

列出设备上所有的反向套接字连接。

  adb reverse <remote> <local> - reverse socket connections
                                 reverse specs are one of:
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>

反向套接字连接。

反向规格是其中之一:

tcp:<端口号>

localabstract:< unix域套接字名称>

localreserved:< unix域套接字名称>

localfilesystem:< unix域套接字名称>

  adb reverse --no-rebind <remote> <local>
                               - same as 'adb reverse <remote> <local>' but fails
                                 if <remote> is already reversed.

与“adb reverse <remote> <local>”相同,但如果<remote>已经反转,则失败。

  adb reverse --remove <remote>
                               - remove a specific reversed socket connection

删除一个特定的反向套接字连接。

  adb reverse --remove-all     - remove all reversed socket connections from device

从设备中移除所有反向套接字连接。

  adb jdwp                     - list PIDs of processes hosting a JDWP transport

负责jdwp传输的流程列表。

  adb install [-lrtsdg] <file>
                               - push this package file to the device and install it
                                 (-l: forward lock application)
                                 (-r: replace existing application)
                                 (-t: allow test packages)
                                 (-s: install application on sdcard)
                                 (-d: allow version code downgrade (debuggable packages only))
                                 (-g: grant all runtime permissions)

将这个包文件推到设备并安装它。

(- l:远期锁定应用程序)

(- r:取代现有的应用程序)

(- t:允许测试包)

(-s:在sdcard上安装应用程序)

(-d:允许版本代码降级(只允许可调试的包))

(g:授予所有运行时权限)

  adb install-multiple [-lrtsdpg] <file...>
                               - push this package file to the device and install it
                                 (-l: forward lock application)
                                 (-r: replace existing application)
                                 (-t: allow test packages)
                                 (-s: install application on sdcard)
                                 (-d: allow version code downgrade (debuggable packages only))
                                 (-p: partial application install)
                                 (-g: grant all runtime permissions)

将这个包文件推到设备上并安装它。

(- l:远期锁定应用程序)

(- r:取代现有的应用程序)

(- t:允许测试包)

(-s:在sdcard上安装应用程序)

(-d:允许版本代码降级(只允许可调试的包))

(- p:部分应用程序安装)

  adb uninstall [-k] <package> - remove this app package from the device
                                 ('-k' means keep the data and cache directories)

从设备中移除该应用程序包。

('-k'意味着保留数据和缓存目录)

  adb bugreport [<zip_file>]   - return all information from the device
                                 that should be included in a bug report.

 从设备中返回所有应该包含在错误报告中的信息。

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.)

将设备数据的存档写入<文件>。

如果没有提供-f选项,则将数据写入“backup”。在当前目录中。

(-apk|-noapk启用/禁用。apk本身在存档文件中;默认是noapk。)

(-obb|-noobb启用/禁用与每个应用程序相关联的任何已安装apk扩展(也称为.obb)文件的备份;默认是noobb。)

(-共享|-noshared启用/禁用该设备共享存储/ SD卡内容的备份;默认是noshared。)

(-所有的方法都是备份所有已安装的应用程序)

(-系统|-nosystem切换是否-所有自动包括系统应用程序;默认是包含系统应用程序)

(<包……>是要备份的应用程序列表。如果传递了-all或-shared标志,那么包列表是可选的。应用程序显式给出。

命令行将被包括,即使-nosystem通常会导致它们被省略。)

adb restore <file>           - restore device contents from the <file> backup archive

从<文件>备份档案中恢复设备内容。

adb disable-verity           - disable dm-verity checking on USERDEBUG builds

禁用对USERDEBUG构建的dm-verity检查。

adb enable-verity            - re-enable dm-verity checking on USERDEBUG builds

重新启用对USERDEBUG构建的dm-verity检查。

  adb keygen <file>            - generate adb public/private key. The private key is stored in <file>,
                                 and the public key is stored in <file>.pub. Any existing files
                                 are overwritten.

生成adb公钥/私钥。私钥存储在<file>中,

而公钥存储在<file>.pub中。任何现有的文件都被覆盖。

  adb help                     - show this help message

显示此帮助信息。

adb version                  - show version num

显示版本号

scripting:

adb wait-for[-<transport>]-<state>
                               - wait for device to be in the given state:
                                 device, recovery, sideload, or bootloader
                                 Transport is: usb, local or any [default=any]

等待设备处于给定状态:

设备,恢复,旁瓣,或引导加载器。

传输是:usb,本地或任何[缺省=任何]

adb start-server - ensure that there is a server running

 确保有一个服务器在运行。

adb kill-server - kill the server if it is running

 如果服务器正在运行,就杀死它。

adb get-state - prints: offline | bootloader | device

打印:离线| bootloader |设备。

adb get-serialno - prints: <serial-number>

 打印:<serial-number>。

adb get-devpath - prints: <device-path>

 打印:<设备路径>。

adb remount - remounts the /system, /vendor (if present) and /oem (if present) partitions on the device read-write

 重登上/系统,/供应商(如果存在)和/oem(如果存在)在设备读写上的分区。

adb reboot [bootloader|recovery]
- reboots the device, optionally into the bootloader or recovery program.

 重新引导设备,可选进入引导加载程序或恢复程序。

adb reboot sideload - reboots the device into the sideload mode in recovery program (adb root required).

 重新引导设备进入恢复程序的旁瓣模式(adb根需要)。

adb reboot sideload-auto-reboot
- reboots into the sideload mode, then reboots automatically after the sideload regardless of the result.

 重新引导到旁瓣模式,然后不管结果如何,在旁瓣后自动重新引导。

adb sideload <file> - sideloads the given package

 旁瓣指定的包。

adb root - restarts the adbd daemon with root permissions

 重新启动带有根权限的adbd守护进程。

adb unroot - restarts the adbd daemon without root permissions

 在没有根权限的情况下重新启动adbd守护进程。

adb usb - restarts the adbd daemon listening on USB

 重新启动adbd守护进程监听usb。

adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified 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. defaultroute debug dump local notty usepeerdns

通过USB运行ppp。

注意:您不应该自动启动一个PPP连接。

<tty>指的是PPP流的tty。如。戴夫:/ dev / omap_csmi_tty1

(参数),例如。defaultroute调试转储本地notty usepeerdns。

adb sync notes: adb sync [ <directory> ]
  <localdir> can be interpreted in several ways:

  - If <directory> is not specified, /system, /vendor (if present), /oem (if present) and /data partitions will be updated.

  - If it is "system", "vendor", "oem" or "data", only the corresponding partition
    is updated.

如果<目录>没有指定,/系统,/供应商(如果存在),/oem(如果存在)和/数据分区将被更新。

-如果是“系统”、“供应商”、“oem”或“数据”,只有对应的分区。

是更新。

internal debugging:

  adb reconnect                  Kick current connection from host side and make it reconnect.

从主机端连接的当前连接,并使其重新连接。

adb reconnect device           Kick current connection from device side and make it reconnect.

adb重新连接设备,从设备端启动当前连接,使其重新连接。

environment 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

打印调试信息。一个逗号分隔的下列值列表。

1或全部,adb,套接字,数据包,rwx, usb, sync, sysdeps, transport, jdwp。

ANDROID_SERIAL               - The serial number to connect to. -s takes priority over this if given.

连接的序列号。如果给予,s优先考虑。

ANDROID_LOG_TAGS             - When used with the logcat option, only these debug tags are printed.

当使用logcat选项时,只打印这些调试标记。

翻译有点蹩脚,以后再完善

补充:

adb logcat | findstr ***   --过滤仅含***的日志

adb logcat *:W        --过滤打印严重级别W及以上的日志

adb logcat -s AndroidRuntime    --过滤手机运行时日志

截屏:

adb shell screencap -p /sdcard/screen.png     --截屏保存到手机的/sdcard/下,图片名为screen.png

adb pull /sdcard/screen.png e:/oppo.png  将手机文件传到电脑,特别注意!!!e盘下必须先有oppo.png文件,不然会失败

adb exec-out screencap -p > screen.png  保存到文件到PC的当前目录。