Global Options: Android Debug Bridge ADB Command

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Android Debug Bridge

ADB Command

You can issue adb commands from a command line on your development machine
or from a script.
adb [-d | -e | -s serial_number] command

If there\'s only one emulator running or only one device connected, the adb
command is sent to that device by default. If multiple emulators are running and/or
multiple devices are attached, you need to use the -d, -e, or -s option to specify the
target device to which the command should be directed.

The table below lists all of the supported adb commands and explains their meaning
and usage.

Global options
Listen on all network interfaces instead of only on  localhost .
adb -a

Direct an adb command to the only attached USB device. Returns an error when
more than one USB device is attached.
adb -d

Direct an adb command to the only running emulator. Returns an error when more
than one emulator is running.
adb -e
Direct an adb command to a specific device, referred to by its adb-assigned serial
number (such as emulator-5556). Overrides the serial number value stored in
the  $ANDROID_SERIAL  environment variable.
adb -s serial_number
The name of the adb server host. The default value is  localhost .
adb -H server
The adb server port number. The default value is  5037 .
adb -P port
Listen on the provided adb server socket. The default value is  tcp:localhost:5037 .
adb -L socket

General commands
Print a list of all devices. Use the  -l  option to include the device descriptions.
adb devices [-l]

Print a list of supported adb commands and their descriptions.


adb help

Print the adb version number.


adb version

Run commands on a device as an app (specified using package_name). This lets


you run commands in adb as if the app you specify is running the command (that is,
you have the same device access that the app has), without requiring root access.
This might be necessary when using adb on a non-rooted device or an emulator with
a Play Store image. The app must be debuggable.
adb run-as package_name

Networking commands
Connect to a device over TCP/IP. If you do not specify a port, then the default
port,  5555 , is used.
adb connect host[:port]
Disconnect from the specified TCP/IP device running on the specified port. If you do
not specify a host or a port, then all devices are disconnected from all TCP/IP ports.
If you specify a host, but not a port, the default port,  5555 , is used.
adb disconnect [host | host:port]

List all forwarded socket connections.


adb forward --list

Forward socket connections from the specified local port to the specified remote port
on the device. You can specify both local and remote ports in the following ways:
 tcp:port . To choose any open port, make the local value  tcp:0 .
 localabstract:unix_domain_socket_name .
 localreserved:unix_domain_socket_name .
 localfilesystem:unix_domain_socket_name .
 dev:character_device_name .
 jdwp:pid .
adb forward [--no-rebind] local remote

Remove the specified forwarded socket connection.


adb forward --remove local

List all reverse socket connections from the device.


adb reverse --list
Reverse a socket connection. The  --no-rebind  option means the reversal fails if the
specified socket is already bound through a previous  reverse  command. You can
specify the port for both local and remote arguments in the following ways:
 tcp:port . To choose any open port, make the remote value  tcp:0 .
 localabstract:unix_domain_socket_name .
 localreserved:unix_domain_socket_name .
 localfilesystem:unix_domain_socket_name .
adb reverse [--no-rebind] remote local

Remove the specified reverse socket connection from the device.


adb reverse --remove remote

Remove all reverse socket connections from the device.


adb reverse --remove-all

You might also like