[Android Software Development] jowinjohnchemban:
Android Debug Bridge (adb) / fastboot

[IMG="1"]https://xdaforums.com/attachment.php?attachmentid=4790627&stc=1&d=1562847544[/IMG]

Android Debug Bridge (adb)

is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device. It is a client-server program that includes three components:

A client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.

A daemon (adbd), which runs commands on a device. The daemon runs as a background process on each device.

A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.

General adb commands

adb <command>

adb devices : list all connected adb interfaces
adb start-server : ensure that there is a server running
adb kill-server : kill the adb server if it is running
adb reconnect : kick connection from host side to force reconnect
adb reconnect device : kick connection from device side to force reconnect
adb reconnect offline : reset offline/unauthorized devices to force reconnect
adb help : show help message
exit : EXIT

[IMG="2"]https://xdaforums.com/attachment.php?attachmentid=4790633&stc=1&d=1562847882[/IMG]

DOWNLOAD​

How adb works

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 devices. It locates emulators by scanning odd-numbered ports in the range 5555 to 5585, the range used by the first 16 emulators. Where the server finds an adb daemon (adbd), it sets up a connection to that port. Note that each emulator uses 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

and so on...

As shown, the emulator connected to adb on port 5555 is the same as the emulator whose console listens on port 5554.

Once the server has set up connections to all devices, you can use adb commands to access those devices. Because the server manages connections to devices and handles commands from multiple adb clients, you can control any device from any client (or from a script).

Enable adb debugging on your device

To use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options.

On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom.

On some devices, the Developer options screen might be located or named differently.

Connect to a device over Wi-Fi

adb usually communicates with the device over USB, but you can also use adb over Wi-Fi after some initial setup over USB, as described below. If you're developing for Wear OS, however, you should instead see the guide to debugging a Wear OS app, which has special instructions for using adb with Wi-Fi and Bluetooth.

Connect your Android device and adb host computer to a common Wi-Fi network accessible to both. Beware that not all access points are suitable; you might need to use an access point whose firewall is configured properly to support adb.

If you are connecting to a Wear OS device, turn off Bluetooth on the phone that's paired with the device.

Connect the device to the host computer with a USB cable.

Set the target device to listen for a TCP/IP connection on port 5555.

adb tcpip 5555

Disconnect the USB cable from the target device.

Find the IP address of the Android device. For example, on a Nexus device, you can find the IP address at Settings > About tablet (or About phone) > Status > IP address. Or, on a Wear OS device, you can find the IP address at Settings > Wi-Fi Settings > Advanced > IP address.

Connect to the device by its IP address.

adb connect device_ip_address

Confirm that your host computer is connected to the target device:

$ adb devices
List of devices attached
device_ip_address:5555 device

You're now good to go!

If the adb connection is ever lost:

Make sure that your host is still connected to the same Wi-Fi network your Android device is.

Reconnect by executing the adb connect step again.

Or if that doesn't work, reset your adb host:

adb kill-server

Then start over from the beginning.

XDA:DevDB Information

adb/fastboot, Tool/Utility for all devices (see above for details)

Contributors

jowinjohnchemban

Source Code: https://xdaforums.com/attachment.php?attachmentid=4790631&stc=1&d=1562847760

Version Information

Status: Stable

Current Stable Version: #

Created 2019-07-11

Last Updated 2019-07-11