- 浏览: 16028486 次
- 性别:
- 来自: 济南
最新评论
-
wu1236:
ef0793cd94337324b6fefc4c9474af5 ...
Android ApiDemos示例解析(87):Media->MediaPlayer -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
本博客文章都为转载,没有任何版权! -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
VPLEX - EMC的RAC -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
qTip2 Show -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
SecureCRT中文乱码、复制粘贴乱码解决办法(修改版)
较详细的adb调试命令
Android Debug Bridge
ADB quickview
<!--[if !supportLists]-->· <!--[endif]-->Manage the state of an emulator or device
<!--[if !supportLists]-->· <!--[endif]-->Run shell commands on a device
<!--[if !supportLists]-->· <!--[endif]-->Manage port forwarding on an emulator or device
<!--[if !supportLists]-->· <!--[endif]-->Copy files to/from an emulator or device
In this document
<!--[if !supportLists]-->1 <!--[endif]-->Issuing ADB Commands
<!--[if !supportLists]-->2 <!--[endif]-->Querying for Emulator/Device Instances
<!--[if !supportLists]-->3 <!--[endif]-->Directing Commands to a Specific Emulator/Device Instance
<!--[if !supportLists]-->4 <!--[endif]-->Installing an Application
<!--[if !supportLists]-->5 <!--[endif]-->Forwarding Ports
<!--[if !supportLists]-->6 <!--[endif]-->Copying Files to or from an Emulator/Device Instance
<!--[if !supportLists]-->7 <!--[endif]-->Listing of adb Commands
<!--[if !supportLists]-->8 <!--[endif]-->Issuing Shell Commands
<!--[if !supportLists]-->9 <!--[endif]-->Enabling logcat Logging
<!--[if !supportLists]-->10 <!--[endif]-->Stopping the adb Server
See also
<!--[if !supportLists]-->11 <!--[endif]-->Emulator
Android Debug Bridge (adb) is a versatile tool lets you manage the state of an emulator instance or Android-powered device. It is a client-server program that includes three components:
<!--[if !supportLists]-->· <!--[endif]-->A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
<!--[if !supportLists]-->· <!--[endif]-->A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
<!--[if !supportLists]-->· <!--[endif]-->A daemon, which runs as a background process on each emulator or device instance.
You can find the adb tool in <sdk>/platform-tools/.
When you start an adb client, the client first checks whether there is an adb server process already running. If there isn't, it starts the server process. When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server.
The server then sets up connections to all running emulator/device instances. It locates emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the range used by emulators/devices. Where the server finds an adb daemon, it sets up a connection to that port. Note that each emulator/device instance acquires a pair of sequential ports — an even-numbered port for console connections and an odd-numbered port for adb connections. For example:
Emulator 1, console: 5554
Emulator 1, adb: 5555
Emulator 2, console: 5556
Emulator 2, adb: 5557 ...
As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.
Once the server has set up connections to all emulator instances, you can use adb commands to control and access those instances. Because the server manages connections to emulator/device instances and handles commands from multiple adb clients, you can control any emulator/device instance from any client (or from a script).
The sections below describe the commands that you can use to access adb capabilities and manage the state of an emulator/device. Note that if you are developing Android applications in Eclipse and have installed the ADT plugin, you do not need to access adb from the command line. The ADT plugin provides a transparent integration of adb into the Eclipse IDE. However, you can still use adb directly as necessary, such as for debugging.
You can issue adb commands from a command line on your development machine or from a script. The usage is:
adb[-d|-e|-s<serialNumber>] <command>
When you issue a command, the program invokes an adb client. The client is not specifically associated with any emulator instance, so if multiple emulators/devices are running, you need to use the-d option to specify the target instance to which the command should be directed. For more information about using this option, see Directing Commands to a Specific Emulator/Device Instance.
Before issuing adb commands, it is helpful to know what emulator/device instances are connected to the adb server. You can generate a list of attached emulators/devices using the devicescommand:
adb devices
In response, adb prints this status information for each instance:
<!--[if !supportLists]-->· <!--[endif]-->Serial number — A string created by adb to uniquely identify an emulator/device instance by its console port number. The format of the serial number is <type>-<consolePort>. Here's an example serial number: emulator-5554
<!--[if !supportLists]-->· <!--[endif]-->State — The connection state of the instance. Three states are supported:
<!--[if !supportLists]-->o <!--[endif]-->offline — the instance is not connected to adb or is not responding.
<!--[if !supportLists]-->o <!--[endif]-->device — the instance is now connected to the adb server. Note that this state does not imply that the Android system is fully booted and operational, since the instance connects to adb while the system is still booting. However, after boot-up, this is the normal operational state of an emulator/device instance.
The output for each instance is formatted like this:
[serialNumber] [state]
Here's an example showing the devices command and its output:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device
If there is no emulator/device running, adb returns no device.
If multiple emulator/device instances are running, you need to specify a target instance when issuing adb commands. To so so, use the -s option in the commands. The usage for the -s option is:
adb-s<serialNumber> <command>
As shown, you specify the target instance for a command using its adb-assigned serial number. You can use the devices command to obtain the serial numbers of running emulator/device instances.
Here is an example:
adb-s emulator-5556 install helloWorld.apk
Note that, if you issue a command without specifying a target emulator/device instance using -s, adb generates an error.
Installing an Application
You can use adb to copy an application from your development computer and install it on an emulator/device instance. To do so, use the install command. With the command, you must specify the path to the .apk file that you want to install:
adb install<path_to_apk>
For more information about how to create an .apk file that you can install on an emulator/device instance, see Android Asset Packaging Tool (aapt).
Note that, if you are using the Eclipse IDE and have the ADT plugin installed, you do not need to use adb (or aapt) directly to install your application on the emulator/device. Instead, the ADT plugin handles the packaging and installation of the application for you.
You can use the forward command to set up arbitrary port forwarding — forwarding of requests on a specific host port to a different port on an emulator/device instance. Here's how you would set up forwarding of host port 6100 to emulator/device port 7100:
adb forward tcp:6100 tcp:7100
You can also use adb to set up forwarding to named abstract UNIX domain sockets, as illustrated here:
adb forward tcp:6100 local:logd
You can use the adb commands pull and push to copy files to and from an emulator/device instance's data file. Unlike the install command, which only copies an .apk file to a specific location, the pull and push commands let you copy arbitrary directories and files to any location in an emulator/device instance.
To copy a file or directory (recursively) from the emulator or device, use
adb pull<remote> <local>
To copy a file or directory (recursively) to the emulator or device, use
adb push<local> <remote>
In the commands, <local> and <remote> refer to the paths to the target files/directory on your development machine (local) and on the emulator/device instance (remote).
Here's an example:
adb push foo.txt/sdcard/foo.txt
The table below lists all of the supported adb commands and explains their meaning and usage.
Category |
Command |
Description |
Comments |
Options |
-d |
Direct an adb command to the only attached USB device. |
Returns an error if more than one USB device is attached. |
-e |
Direct an adb command to the only running emulator instance. |
Returns an error if more than one emulator instance is running. |
|
-s <serialNumber> |
Direct an adb command a specific emulator/device instance, referred to by its adb-assigned serial number (such as "emulator-5556"). |
If not specified, adb generates an error. |
|
General |
devices |
Prints a list of all attached emulator/device instances. |
See Querying for Emulator/Device Instances for more information. |
help |
Prints a list of supported adb commands. |
|
|
version |
Prints the adb version number. |
|
|
Debug |
logcat [<option>] [<filter-specs>] |
Prints log data to the screen. |
|
bugreport |
Prints dumpsys, dumpstate, andlogcat data to the screen, for the purposes of bug reporting. |
|
|
jdwp |
Prints a list of available JDWP processes on a given device. |
You can use the forward jdwp:<pid> port-forwarding specification to connect to a specific JDWP
process. For example: |
|
Data |
install <path-to-apk> |
Pushes an Android application (specified as a full path to an .apk file) to the data file of an emulator/device. |
|
pull <remote> <local> |
Copies a specified file from an emulator/device instance to your development computer. |
|
|
push <local> <remote> |
Copies a specified file from your development computer to an emulator/device instance. |
|
|
Ports and Networking |
forward <local> <remote> |
Forwards socket connections from a specified local port to a specified remote port on the emulator/device instance. |
Port specifications can use these schemes: <!--[if !supportLists]-->· <!--[endif]-->tcp:<portnum> <!--[if !supportLists]-->· <!--[endif]-->local:<UNIX domain socket name> <!--[if !supportLists]-->· <!--[endif]-->dev:<character device name> <!--[if !supportLists]-->· <!--[endif]-->jdwp:<pid>
|
ppp <tty> [parm]... |
Run PPP over USB. <!--[if !supportLists]-->· <!--[endif]--><tty> — the tty for PPP stream. For exampledev:/dev/omap_csmi_ttyl. <!--[if !supportLists]-->· <!--[endif]-->[parm]... — zero or more PPP/PPPD options, such asdefaultroute, local, notty, etc. Note that you should not automatically start a PPP connection. |
|
|
Scripting |
get-serialno |
Prints the adb instance serial number string. |
See Querying for Emulator/Device Instances for more information. |
get-state |
Prints the adb state of an emulator/device instance. |
||
wait-for-device |
Blocks execution until the device is online — that is, until the instance state is device. |
You can prepend this command to other adb commands, in which case adb will wait until the emulator/device instance is connected before issuing the other commands. Here's an example: adb wait-for-device shell getprop Note that this command does not cause adb to wait until the entire system is fully booted. For that reason, you should not prepend it to other commands that require a fully booted system. As an example, the install requires the Android package manager, which is available only after the system is fully booted. A command such as adb wait-for-device install<app>.apk would issue the install command as soon as the emulator or device instance connected to the adb server, but before the Android system was fully booted, so it would result in an error. |
|
Server |
start-server |
Checks whether the adb server process is running and starts it, if not. |
|
kill-server |
Terminates the adb server process. |
|
|
Shell |
shell |
Starts a remote shell in the target emulator/device instance. |
See Issuing Shell Commands for more information. |
shell [<shellCommand>] |
Issues a shell command in the target emulator/device instance and then exits the remote shell. |
Adb provides an ash shell that you can use to run a variety of commands on an emulator or device. The command binaries are stored in the file system of the emulator or device, in this location:
/system/bin/...
You can use the shell command to issue commands, with or without entering the adb remote shell on the emulator/device.
To issue a single command without entering a remote shell, use the shell command like this:
adb[-d|-e|-s{<serialNumber>}] shell<shellCommand>
To drop into a remote shell on a emulator/device instance, use the shell command like this:
adb[-d|-e|-s{<serialNumber>}] shell
When you are ready to exit the remote shell, use CTRL+D or exit to end the shell session.
The sections below provide more information about shell commands that you can use.
From an adb remote shell, you can use the sqlite3 command-line program to manage SQLite databases created by Android applications. The sqlite3 tool includes many useful commands, such as.dump to print out the contents of a table and .schema to print the SQL CREATE statement for an existing table. The tool also gives you the ability to execute SQLite commands on the fly.
To use sqlite3, enter a remote shell on the emulator instance, as described above, then invoke the tool using the sqlite3 command. Optionally, when invoking sqlite3 you can specify the full path to the database you want to explore. Emulator/device instances store SQLite3 databases in the folder /data/data/<package_name>/databases/.
Here's an example:
$ adb-s emulator-5554 shell
#
sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
SQLite version3.3.12
Enter ".help" for instructions
.... enter commands, then quit...
sqlite> .exit
Once you've invoked sqlite3, you can issue sqlite3 commands in the shell. To exit and return to the adb remote shell, use exit or CTRL+D.
UI/Application Exerciser Monkey
The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.
The simplest way to use the monkey is with the following command, which will launch your application and send 500 pseudo-random events to it.
$ adb shell monkey-v-p your.package.name500
For more information about command options for Monkey, see the complete UI/Application Exerciser Monkey documentation page.
The table below lists several of the adb shell commands available. For a complete list of commands and programs, start an emulator instance and use the adb -help command.
adb shell ls/system/bin
Help is available for most of the commands.
Shell Command |
Description |
Comments |
dumpsys |
Dumps system data to the screen. |
The Dalvik Debug Monitor Service (DDMS) tool offers integrated debug environment that you may find easier to use. |
dumpstate |
Dumps state to a file. |
|
logcat [<option>]... [<filter-spec>]... |
Enables radio logging and prints output to the screen. |
|
dmesg |
Prints kernel debugging messages to the screen. |
|
start |
Starts (restarts) an emulator/device instance. |
|
stop |
Stops execution of an emulator/device instance. |
|
The Android logging system provides a mechanism for collecting and viewing system debug output. Logs from various applications and portions of the system are collected in a series of circular buffers, which then can be viewed and filtered by the logcat command.
You can use the logcat command to view and follow the contents of the system's log buffers. The general usage is:
[adb] logcat[<option>] ... [<filter-spec>] ...
The sections below explain filter specifications and the command options. See Listing of logcat Command Options for a summary of options.
You can use the logcat command from your development computer or from a remote adb shell in an emulator/device instance. To view log output in your development computer, you use
$ adb logcat
and from a remote adb shell you use
# logcat
Every Android log message has a tag and a priority associated with it.
<!--[if !supportLists]-->· <!--[endif]-->The tag of a log message is a short string indicating the system component from which the message originates (for example, "View" for the view system).
<!--[if !supportLists]-->· <!--[endif]-->The priority is one of the following character values, ordered from lowest to highest priority:
<!--[if !supportLists]-->o <!--[endif]-->V — Verbose (lowest priority)
<!--[if !supportLists]-->o <!--[endif]-->D — Debug
<!--[if !supportLists]-->o <!--[endif]-->I — Info
<!--[if !supportLists]-->o <!--[endif]-->W — Warning
<!--[if !supportLists]-->o <!--[endif]-->E — Error
<!--[if !supportLists]-->o <!--[endif]-->F — Fatal
<!--[if !supportLists]-->o <!--[endif]-->S — Silent (highest priority, on which nothing is ever printed)
You can obtain a list of tags used in the system, together with priorities, by running logcat and observing the first two columns of each message, given as <priority>/<tag>.
Here's an example of logcat output that shows that the message relates to priority level "I" and tag "ActivityManager":
I/ActivityManager( 585): Starting activity: Intent { action=android.intent.action...}
To reduce the log output to a manageable level, you can restrict log output using filter expressions. Filter expressions let you indicate to the system the tags-priority combinations that you are interested in — the system suppresses other messages for the specified tags.
A filter expression follows this format tag:priority ..., where tag indicates the tag of interest and priority indicates the minimum level of priority to report for that tag. Messages for that tag at or above the specified priority are written to the log. You can supply any number of tag:priority specifications in a single filter expression. The series of specifications is whitespace-delimited.
Here's an example of a filter expression that suppresses all log messages except those with the tag "ActivityManager", at priority "Info" or above, and all log messages with tag "MyApp", with priority "Debug" or above:
adb logcatActivityManager:IMyApp:D*:S
The final element in the above expression, *:S, sets the priority level for all tags to "silent", thus ensuring only log messages with "View" and "MyApp" are displayed. Using *:S is an excellent way to ensure that log output is restricted to the filters that you have explicitly specified — it lets your filters serve as a "whitelist" for log output.
The following filter expression displays all log messages with priority level "warning" and higher, on all tags:
adb logcat*:W
If you're running logcat from your development computer (versus running it on a remote adb shell), you can also set a default filter expression by exporting a value for the environment variableANDROID_LOG_TAGS:
export ANDROID_LOG_TAGS="ActivityManager:I MyApp:D *:S"
Note that ANDROID_LOG_TAGS
filter is not exp
发表评论
相关推荐
智能机的ADB调试命令整理,覆盖调试范围较广,需要花时间熟悉了解
Android 无线调试 WIFI调试 工具APK 确保系统已获取ROOT权限,点击开启后,电脑通过adb命令 adb connect 192.168.0.101:5555进行连接
用于Android系统的串口调试工具和adb工具以及使用文档说明
易语言 调试安卓手机 adb简单实例 adb
WIFI ADB调试工具,利用Eclipse无线调试程序,摆脱数据线
ADB 即 Android Debug Bridge,Android调试桥。•基本用法 •设备连接管理 •应用管理 •与应用交互 •文件管理 •模拟按键/输入
adb命令大全,让你可以更方便的使用ADB。对android项目进行分析。adb命令大全,让你可以更方便的使用ADB。对android项目进行分析。adb命令大全,让你可以更方便的使用ADB。对android项目进行分析。
绿色,可以直接运行; 在cmd里敲命令即可;
ADB命令类模块,是易语言连接虚拟机工具,可以进行很多手机操作,如安装软件、卸载软件、系统升级、运行shell命令等等。
Android 调试桥(adb)是多种用途的工具,该工具可以帮助你你管理设备或模拟器 的状态。 可以通过下列几种方法加入adb: • 在设备上运行shell命令 • 通过端口转发来管理模拟器或设备 • 从模拟器或设备上拷贝来或拷贝...
Android手机开发用到的大部分ADB调试命令均在其中,个人整理。
打开解压该文件夹,win10中按住shift点击鼠标右键,选择在此打开“powershell”即可使用各种adb命令来调试安卓手机(前提,手机已经连接到PC并且已经安装了手机品牌的驱动程序),使用该工具包可以开启“绿色守护”...
本文为大家汇总了Android Studio ADB网络调试的使用方法,供大家参考,具体内容如下 ...1.使用AS命令控制台adb命令手动调试 USB连接上手机,在AS底部Terminal窗口中输入adb tcpip 5555 然后接着输入adb sh
酷派w711无线adb调试及root权限破解工具.rar
android开机自动运行APP实现方式其实很简单。在android系统运行时,会发出“android.intent.action.BOOT_COMPLETED”这个系统广播,因此我们监听它,并进行打开APP的操作即可。现在大多数的android手机系统都默认...
实际开发总常用adb来调试真机,这是一些常规的命令,欢迎完善
安装此apk后,打开手机无线调试功能(开发者选项中,各品牌手机方式不同),打开apk,自动连接上手机adb,实现在本机执行adb命令,不用依赖电脑。
这里是一些android的adb常用命令,能够知道大家进行一些手机开发的调试。 这里只是我的一些小小的见解,希望对大家有帮助
软件测试--adb命令使用大全介绍,ADB是我们用来操作(调试)android设备(比如android手机)的一套指令集
万能android开发调试工具,免去安装,放到硬盘里就能直接用。 在cmd命令提示符中,进到adb.exe目录,直接就可以用adb命令操作。