zoukankan      html  css  js  c++  java
  • Android adb命令

    做了这么长时间的开发与管理,在命令上总是自见则过,往往却忽视了在其命令上的分享过程,所以现在稍微有点时间就把
    其命令的相关操作来简单的扫盲一番吧,也系统通过这种方式去授之以渔而不是鱼,好了,我以图解的方式来展示,当然我的习惯就是任何东西先看帮助文档或者命令,就今天我们这里要讲解的ADB命令在命令行中可以通过命令帮助来进行详细了解,废话不多说,先上图吧:
    加载中...
    加载中...
    加载中...
    加载中...
    以上为使用help来显示其相关的命令使用说明,当然那个如果你的英文足够好的话,其实这些都很简单,当然,如你不太习惯去看这些英文描述的话,那接下来就由我来帮助处理这样的问题吧,好了,我就以最初始的理解方式来进行翻译与讲解吧,OK:
    Android Debug Bridge version 1.0.29
    这是关于Android调试牌的1.0.29版本

     -d                            - directs command to the only connected USB device
    通过这个直接的命令仅仅是去连接USB设备
                                     returns an error if more than one USB device is present.
    如果有多个USB设备同时出现的时候就会返回一个错误信息
     -e                            - directs command to the only running emulator.
    直接使用这个命令符号来运行模拟器
                                     returns an error if more than one emulator is running.
    如果存在多个模拟器同时运行时会在当前返回一个错误信息
     -s <serial number>            - directs command to the USB device or emulator with
                                     the given serial number. Overrides ANDROID_SERIAL
                                     environment variable.
    通过这个直接的命令去展示其USB设备或者模拟器的序列号,彼此覆盖时会使其环境变量是可变的
     -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的环境变量,但必须是一个绝对路径.
     devices                       - list all connected devices
    通过此命令可以列出所有已经连接的设备
     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 file/dir to device
    PUSH命令:即复制一个文件或者目录进设备中
      adb pull <remote> [<local>]  - copy file/dir from device
    PULL命令:即复制一个文件或者目录进设备中
      adb sync [ <directory> ]     - copy host->device only if changed
                                     (-l means list but don't copy)
                                     (see 'adb help all')
    SYNC:复制主机内容进设备,仅仅是设备进行改变时对其内容进行同步处理的操作,括号里有说明:我的意思是列出但是不需要复制,可参考帮助ALL
      adb shell                    - run remote shell interactively
    SHELL:运行远程SHELL与之交互
      adb shell <command>          - run remote shell command
    SHELL:直接运行远程SHELL命令
      adb emu <command>            - run emulator console command
    EMU:运行模拟器监控信息面板命令
      adb logcat [ <filter-spec> ] - View device log
    阅览设备日志
      adb forward <local> <remote> - forward socket connections
    远期套接字连接 www.2cto.com
                                     forward specs are one of:
    远期规格显示的一个标准是:
                                       tcp:<port>
    TCP端口号
                                       localabstract:<unix domain socket name>
    本地抽象:UNIX域名的SOCKET名称
                                       localreserved:<unix domain socket name>
    本地服务:UNIX域名/SOCKET名称
                                       localfilesystem:<unix domain socket name>
    本地文件系统:UNIX域名/SOCKET名称
                                       dev:<character device name>
    设备:字符设备名称
                                       jdwp:<process pid> (remote only)
    远程进程ID
      adb jdwp                     - list PIDs of processes hosting a JDWP transport
    列出相关的进程ID为主机进程的一个JAVA调试的无线协议的传输
    说道JDWP,我简单对其说明下,说明是JDWP呢,JDWP的全写是:Java Debug Wire Protocol:即JAVA调试器无线协议,它定义了调试器(Debugger)和被调试的JAVA虚拟机(target vm)之间的通信协议,在这里,我更要说明下:Debugger与Target vm,Target vm 中运行着我们希望要调试的程序,它与一般运行的Java虚拟机没有什么区别,只是在启动时加载了Agent JDWP 从而具备了调试功能。而debugger 就是我们熟知的调试器,它向运行中的target vm 发送命令来获取target vm 运行时的状态和控制Java 程序的执行。Debugger 和target vm 分别在各自的进程中运行,他们之间的通信协议就是JDWP。JDWP 与其他许多协议不同,它仅仅定义了数据传输的格式,但并没有指定具体的传输方式。这就意味着一个JDWP 的实现可以不需要做任何修改就正常工作在不同的传输方式上(在JDWP 传输接口中会做详细介绍)。JDWP 是语言无关的。理论上我们可以选用任意语言实现JDWP。然而我们注意到,在JDWP 的两端分别是target vm 和debugger。Target vm 端,JDWP 模块必须以Agent library 的形式在Java 虚拟机启动时加载,并且它必须通过Java 虚拟机提供的JVMTI 接口实现各种debug 的功能,所以必须使用C/C++ 语言编写。而debugger 端就没有这样的限制,可以使用任意语言编写,只要遵守JDWP 规范即可。JDI(Java Debug Interface)就包含了一个Java 的JDWP debugger 端的实现(JDI 将在该系列的下一篇文章中介绍),JDK 中调试工具jdb 也是使用JDI 完成其调试功能的。以上介绍的JDWP agent在调试中扮演的角色为下图所示:
    加载中...
    其实我们对其协议简单分析下,我们可以通过下图来了解到起握手协议的简单过程:
    加载中...
    最后了解下其架构吧:
    加载中...
    好,从以上我们了解了其JDWP的相关信息,更详细的信息与操作请在GOOGLE里详细查询与了解吧.
      adb install [-l] [-r] [-s] <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)
                                     ('-s' means install on SD card instead of internal storage)
    通过这个命令来对其打包的APK进行安装进设备中,-l意味着远期锁定期APP,-r意味着需要重新安装这个APP,当然需要对其数据进行保持,-s意味着安装进SD卡中
      adb uninstall [-k] <package> - remove this app package from the device
                                     ('-k' means keep the data and cache directories)
    通过这个命令来卸载其安装好的APK,即移除当前的APP来自设备的包,-k意味着保持数据域缓存目录
      adb bugreport                - return all information from the device
                                     that should be included in a bug report.
    通过这个命令可以对其调试出的信息(设备的信息)输出并显示出来

      adb backup [-f <file>] [-apk|-noapk] [-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.)
                                     (-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 restore <file>           - restore device contents from the <file> backup archive

    对其备份的归档文件可以重新对其内容进行设备的存储
      adb help                     - show this help message
    显示帮助信息
      adb version                  - show version num
    显示去版本号
    scripting:
    脚本
      adb wait-for-device          - block until device is online
    等待期设备知道设备在线时
      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
    获得其设备的状态
      adb get-serialno             - prints: <serial-number>
    获得一系列的序列号信息
      adb status-window            - continuously print device status for a specified device
    连续打印指定的设备状态
      adb remount                  - remounts the /system partition on the device read-write
    对其设备读写进行重新安装  
    adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
    重新加载或者是去恢复程序等 
     adb reboot-bootloader        - reboots the device into the bootloader
    对其重新启动的设备进行加载
      adb root                     - restarts the adbd daemon with root permissions
    重新启动后获得ROOT权限
      adb usb                      - restarts the adbd daemon listening on USB
    重新启动来监听器USB
      adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port
    重新启动TCP来监听指定的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


    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.


    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
      ANDROID_SERIAL               - The serial number to connect to. -s takes priority over this if given.
      ANDROID_LOG_TAGS             - When used with the logcat option, only these debug tags are printed.
    以上部分由于时间问题就不翻译与理解了,其实后面几句都非常好理解,自己也尝试着去做一下吧,
    下面就进行一个简单的例子:
    显示日志: adb logcat | more
    加载中...
    列出设备: adb devices
    加载中...
    OK,以上是简单的两个命令列子,你自己可以根据实际情况去带入相关参数即可对其命令进行校验了,好了,希望能给大家做一定的参考与学习.......
     

  • 相关阅读:
    rsync介绍和配置自动同步
    haproxy 配置httpd和httpds负载均衡
    haproxy配置及使用
    lvs之搭建NAT模式的HTTPS负载集群
    lvs配置之DR模式
    lvs配置之NAT模式
    LVS集群
    lvs四种工作模式,负载调度的介绍
    zabbix页面介绍
    zabbix自定义监控进程、日志、mysql主从
  • 原文地址:https://www.cnblogs.com/maksim3000/p/3316889.html
Copyright © 2011-2022 走看看