`
gaojingsong
  • 浏览: 1157059 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

【adb操作命令详解及大全】

阅读更多

 

查看版本

$ adb version

Android Debug Bridge version 1.0.36
Revision 8f855a3d9b35-android

查看连接设备

输入以下命令可以查询已连接的设备与模拟器:

$ adb devices

List of devices attached
02ae0c1021089daf       device

安装一个apk,执行以下命令:

adb install <apkfile>

// 如: adb install demo.apk
如果不是当前目录,则后面要跟路径名:

adb install /Users/storm/temp/demo.apk
保留数据和缓存文件,重新安装apk:

adb install -r demo.apk
安装apk到sd卡:

adb install -s demo.apk
卸载

直接卸载:

adb uninstall <package>

// 如:adb uninstall com.stormzhang.demo
卸载 app 但保留数据和缓存文件:

adb uninstall -k com.stormzhang.demo

启动/停止 Server

一般来说,下面两个命令基本不会用到,因为只要设备连接正确,会自动启动 adb server 的,不过大家也需要知道这俩命令:

启动 adb server :

adb start-server

停止 adb server :

adb kill-server

列出手机装的所有app的包名:

adb shell pm list packages

列出系统应用的所有包名:

adb shell pm list packages -s

列出除了系统应用的第三方应用包名:

adb shell pm list packages -3

使用 grep 来过滤:

adb shell pm list packages | grep qq

清除应用数据与缓存

有些时候我们测试需要清除数据与缓存,则需要用到如下命令:

adb shell pm clear <packagename>

// 如:adb shell pm clear com.stormzhang.demo

启动应用

如果我们想要通过 adb 来启动应用
adb shell am start -n com.stormzhang.demo/.ui.SplashActivity

强制停止应用

有些时候应用卡死了,需要强制停止,则执行以下命令:

adb shell am force-stop <packagename>

// 如:adb shell am force-stop cn.androidstar.demo

查看日志

adb logcat

重启

adb reboot

获取序列号

$adb get-serialno

02ae0c1021089daf

获取 MAC 地址

$adb shell  cat /sys/class/net/wlan0/address

bc:f5:ac:f9:f7:c8

查看设备型号

$adb shell getprop ro.product.model

Nexus 5

查看 Android 系统版本

$adb shell getprop ro.build.version.release

7.0.1

查看屏幕分辨率

$adb shell wm size

Physical size: 1080×1920

查看屏幕密度

$adb shell wm density



 

 

 

 

参考命令:

Microsoft Windows XP [版本 5.1.2600]

(C) 版权所有 1985-2001 Microsoft Corp.

 

C:\Documents and Settings\Administrator>cd C:\share_soft\adb

 

C:\share_soft\adb>adb.exe

Android Debug Bridge version 1.0.26

 

 -d                            - directs command to the only connected USB device

                                 returns an error if more than one USB device is present.

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

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

 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.

 disconnect [<host>[:<port>]]  - disconnect from a TCP/IP device.

                                 Port 5555 is used by default if no port number is specified.

                                 Using this ocmmand with no additional arguments

                                 will disconnect from all connected TCP/IP devices.

 

device commands:

  adb push <local> <remote>    - copy file/dir to device

  adb pull <remote> [<local>]  - copy file/dir from device

  adb sync [ <directory> ]     - copy host->device only if changed

                                 (-l means list but don't copy)

                                 (see 'adb help all')

  adb shell                    - run remote shell interactively

  adb shell <command>          - run remote shell command

  adb emu <command>            - run emulator console command

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

  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)

  adb jdwp                     - list PIDs of processes hosting a JDWP transport

  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)

  adb uninstall [-k] <package> - remove this app package from the device

                                 ('-k' means keep the data and cache directories)

  adb bugreport                - return all information from the device

                                 that should be included in a bug report.

 

  adb help                     - show this help message

  adb version                  - show version num

 

DATAOPTS:

 (no option)                   - don't touch the data partition

  -w                           - wipe the data partition

  -d                           - flash the data partition

 

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

  adb usb                      - restarts the adbd daemon listening on USB

  adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port

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.

 

C:\share_soft\adb>

  • 大小: 220.2 KB
  • 大小: 187.9 KB
0
0
分享到:
评论

相关推荐

    adb操作命令详解及大全

    adb操作命令详解及大全,adb操作命令详解及大全,adb操作命令详解及大全

    ADB 操作命令详解及用法大全.pdf

    ADB 操作命令详解及用法大全.pdf android debug bridge学习资料, 给需要app模拟用的同学一起学习

    adb操作命令详解.doc

    adb操作命令详解.doc adb操作命令详解.doc

    adb操作命令详解[收集].pdf

    adb操作命令详解[收集].pdf

    adb操作命令详解.pdf

    adb操作命令详解.pdf

    adb用法大全

    包含:adb用法大全.pdf adb 操作命令详解及大全.pdf adb用法大全

    adb.exe 命令详解及adb安装说明

    ADB全称Android Debug Bridge, 是android sdk里的一个工具, 用这个工具可以直接操作管理android模拟器或者真实的andriod设备(如G1手机). 它的主要功能有: * 运行设备的shell(命令行) * 管理模拟器或设备的端口映射 *...

    adb工具操作命令详解

    adb(Android Debug Bridge)是Android提供的一个通用的调试工具,说白了就是debug工具。借助这个工具,我们可以管理设备或手机模拟器的状态。 个人常用功能 1、在设备上运行shell命令 2、安装卸载程序 3、推送文件到...

    adb命令详解

    adb命令详解 包括adb工具箱 详细操作

    ADB常用指令汇总及解析

    在安卓测试过程中,测试人员经常需要进行装包、卸载以及重启等安卓设备的操作,熟练使用ADB命令,可以提高测试效率。文档是个人入职大半年来所有常用的ADB指令汇总整理及解析,适用于所有安卓测试入门的小伙伴。

    android手机Monkey测试操作手册

    一、Monkey 二、环境搭建 三、Monkey:连接真机 四、Monkey命令详解 五、一个简单的monkey命令: 六、启动Monkey

    ios命令行调试工具libimobiledevice详解

    IOS下面也有类似于android平台adb的工具,可以用来查看手机信息,备份,恢复,手机挂在目录等,本文档介绍了常用的几种方法

    Android亮屏和熄屏控制实例详解

    本文实例讲述了Android亮屏和熄屏控制实现方法。分享给大家供大家参考,具体如下: 一、概述 我们的Android应用程序很多需要和亮屏和熄屏打交道,比如闹钟的时候,需要保持亮屏,之后又需要熄屏。...

    Monkey测试–monkey压力测试及性能监控

    adb命令:adb是Android调试桥 monkey使用 做App性能的测试 monkey操作的是手机里面的app 连接手机:打开USB调试模式 使用adb连接:adb devices(真机连接) monkey详解 包:在app上唯一标识一个APP的apppackage adb

    Android中删除sdcard里文件的命令

    有时我们需要删除android模拟器或手机上的sd卡文件,特别是... 您可能感兴趣的文章:Android用ListView显示SDCard文件列表的小例子android读取sdcard路径下的文件的方法Android对sdcard扩展卡文件操作实例详解andro

    monkey工具详解

    1.为什么要开展压力测试?提高产品的稳定性提高产品的...monkeyScript是一组可以被monkey识别的命令集合Monkeyscript可以完成重复固定的操作;monkeyRunner5.什么是monkeyRunnermonkeyRunner提供了一系列的APImonkeyR

    linux – CenterOS 搞定 【端口】 + 【MySQL / Mariadb】: 安装、远程连接

    《centos7 安装Mariadb》 《MySQL – 修改密码(重置密码/丢失密码) – 方法汇总 – 【包括 MySQL5.7及8.0.11版本后】》 《Linux环境下修改MySQL端口方法》 列出所有端口 netstat -ntlp ...《Linux awk命令详解》 作者

    autoJS1688示例.zip

    adb5037常用命令.js aes加解密000.js AES加解密demo.js after work.js AJ-网易云签到.js AJ_api_search(1).js AJ_api_search.js aj内置文件管理.js AJ功能搜索(1).js AJ功能搜索.js aj数据文件管理.js ...

Global site tag (gtag.js) - Google Analytics