Android ADB Android Debug Bridge suggest change

Connect ADB to a device via WiFi

The standard ADB configuration involves a USB connection to a physical device.

If you prefer, you can switch over to TCP/IP mode, and connect ADB via WiFi instead.

Not rooted device

  1. Get on the same network:
  1. Connect the device to the host computer with a USB cable.
  2. Connect adb to device over network:

While your device is connected to adb via USB, do the following command to listen for a TCP/IP connection on a port (default 5555):

For example:

adb tcpip 5555
adb connect 192.168.0.101:5555

If you don’t know your device’s IP you can:

1. Connect the device to the computer via USB
2. In a command line, type `adb shell ifconfig` and copy your device's IP address

To revert back to debugging via USB use the following command:

adb usb

You can also connect ADB via WiFi by installing a plugin to Android Studio. In order to do so, go to Settings > Plugins and Browse repositories, search for ADB WiFi, install it, and reopen Android Studio. You will see a new icon in your toolbar as shown in the following image. Connect the device to the host computer via USB and click on this AndroidWiFiADB icon. It will display a message whether your device is connected or not. Once it gets connected you can unplug your USB.


Rooted device

Note: Some devices which are rooted can use the ADB WiFi App from the Play Store to enable this in a simple way. Also, for certain devices (especially those with CyanogenMod ROMs) this option is present in the Developer Options among the Settings. Enabling it will give you the IP address and port number required to connect to adb by simply executing adb connect <ip address>:<port>.

When you have a rooted device but don’t have access to a USB cable

The process is explained in detail in the following answer: http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp/3623727#3623727 The most important commands are shown below.

Open a terminal in the device and type the following:

su
setprop service.adb.tcp.port <a tcp port number>
stop adbd
start adbd

For example:

setprop service.adb.tcp.port 5555

And on your computer:

adb connect <ip address>:<a tcp port number>

For example:

adb connect 192.168.1.2:5555

To turn it off:

setprop service.adb.tcp.port -1
stop adbd
start adbd

Avoid timeout

By default adb will timeout after 5000 ms. This can happen in some cases such as slow WiFi or large APK.

A simple change in the Gradle configuration can do the trick:

android {
    adbOptions {
        timeOutInMs 10 * 1000
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents