How can I connect to Android with ADB over TCP?
This is really simple if your phone is rooted.
Download a terminal emulator from Google Play (there are lots that are free). Make sure that your Android device is connected to your Wi-Fi and get the Wi-Fi IP address. Open the terminal program and type:
su setprop service.adb.tcp.port 5555 stop adbd start adbd
Now go to your computer (assuming that you are using Windows) and create a shortcut on the desktop for "cmd.exe" (without the quotations).
Right click on the cmd shortcut and choose
"Run as Administrator"
Change to your
adb connect ***wifi.ip.address***:5555 (example: adb connect 192.168.0.105:5555)
adb should now say that you are connected.
Note: if you are too fast to give the connect command it may fail. So try at least two times five seconds apart before you say this doesn't work.
I am attempting to debug an application on a Motorola Droid, but I am having some difficulty connecting to the device via USB. My development server is a Windows 7 64-bit VM running in Hyper-V, and so I cannot connect directly via USB in the guest or from the host.
I installed a couple of different USB-over-TCP solutions, but the connection appears to have issues since the ADB monitor reports "devicemonitor failed to start monitoring" repeatedly. Is there a way to connect directly from the client on the development machine to the daemon on the device using the network instead of the USB connection or possibly another viable options?
connect <host>:<port> - Connect to a device via TCP/IP
That's a command-line option by the way.
You should try connecting the phone to your Wi-Fi, and then get its IP address from your router. It's not going to work on the cell network.
The port is 5554.
Make sure both your adb host computer and Android device are on the same Wifi network.
Connect the Android device with the computer using your USB cable. As soon as you do that, your host computer will detect your device and adb will start running in the USB mode on the computer. You can check the attached devices with
adb devices whereas ensure that adb is running in the USB mode by executing
$ adb usb restarting in USB mode $ adb devices List of devices attached ZX1D63HX9R device
Restart adb in tcpip mode with this command:
$ adb tcpip 5556 restarting in TCP mode port: 5556
Find out the IP address of the Android device. There are several ways to do that:
- WAY: 1 Go to Settings -> About phone/tablet -> Status -> IP address.
- WAY: 2 Go to the list of Wi-fi networks available. The one to which you’re connected, tap on that and get to know your IP.
- WAY: 3 Try
$ adb shell netcfg.
Now that you know the IP address of your device, connect your adb host to it.
$ adb connect 192.168.0.102:5556 already connected to 192.168.0.102:5556 $ adb devices List of devices attached ZX1D63HX9R device 192.168.0.102:5556 device
Remove the USB cable and you should be connected to your device. If you don’t see it in
adb devices then just reconnect using the previous step’s command:
$ adb connect 192.168.0.102:5556 connected to 192.168.0.102:5556 $ adb devices List of devices attached 192.168.0.102:5556 device
Either you’re good to go now or you’ll need to kill your adb server by executing
adb kill-server and go through all the steps again once more.
Hope that helps!
adb tcpip 5555
Weird, but this only works for me if I have the USB cable connected, then I can unplug the usb and go for it with everything else adb.
and the same when returning to usb,
will only work if usb is connected.
It doesn't matter if I issue the
setprop service.adb.tcp.port 5555
setprop service.adb.tcp.port -1
then stop & start adbd, I still need the usb cable in or it doesn't work.
So, if my ADB over usb wasn't working, I bet I wouldn't be able to enable ADB over WiFi either.
From a computer on a non-rooted device
(Note that this can be done using a rooted device as well, but you can use a shell on a rooted device which doesn't require a USB connection)
Firstly, open command prompt (CMD). If you use Android Studio or IntelliJ there is a console included in there you can use.
If possible, open the SDK location, right click, and press "start command prompt here". Not all have this option so you have to do this (/these) commands as well:
Change the drive (if applicable)
And access the sdk and platform tools. Replace this path with your SDK location:
Now you have access to the Android debug bridge.
Now, with the device connected to the computer, do:
adb tcpip <port> adb connect <ip>:<port>
Where is the port you want to connect to (default is
5555) and is the IP of the device you want to connect to.
5555 is the default port and just writing the IP address connects it. If you use a custom port you can at least improve the security a bit. USB debugging over wifi can be abused, but only if the device is connected to the computer who wants to abuse the device. Using a non-default port at least makes it a bit harder to connect.
If you use a custom port, make sure to add it after the IP. Writing no port connects to
5555 and if you didn't use that the connection will fail.
You can find the IP address of a device in two ways:
Depending on your device, the exact names may vary. Open settings and go to About device -> Status -> IP address
Use ADB to get the IP
From the console, do:
adb shell ip -f inet addr show wlan0
And once you are finished with the connection, you can disconnect the device from your computer by doing:
adb disconnect <ip>:<port>
Or no IP to disconnect all devices. If you used a custom port, you must specify which port to disconnect from. The default is 5555 here as well.
To disable the port (if that is something you want to do) you do this command with the device connected:
Or you can restart the device to remove the tcpip connection
From a computer on a rooted device
Firstly, you need access to the shell. You either connect the device using a usb cable and use
adb shell or download an app from Google Play, FDroid, or some other source.
Then you do:
su setprop service.adb.tcp.port <port> stop adbd start adbd
And to connect the device, you do as in the non-rooted version by doing
adb connect <ip>:<port>.
And if you want to disable the port and go back to USB listening:
setprop service.adb.tcp.port -1 stop adbd start adbd
You can also use an Android Studio plugin to do it for you (don't remember the name right now), and for rooted users there's also the option of downloading an Android app to set up the phone connection (adb connect is probably still required).
Some phones have a setting in developer options (this applies to some unrooted phones, though probably some rooted phones too) that allows for toggling ADB over wifi from the device itself without root or a computer connection to start it. Though there are few phones that have that
Assume you saved adb path into your Windows environment path
Activate debug mode in Android
Connect to pc via usb
Open command prompt type: adb tcpip 5555
Disconnect your tablet or smartphone from pc
Open command prompt type: adb connect IPADDRESS (IPADDRESS is the DHCP/IP address of your tablet or smartphone, which you can find by Wi-Fi -> current connected network)
Now in command prompt you should see the result like: connected to xxx.xxx.xxx.xxx:5555
If you want to be able to do it on a button click then:
- In Android Studio -> Settings/Preferences -> Plugins -> Browse Repositories
- Search 'ADB wifi'
- Install and restart android studio
- Connect your device (with USB Debugging enabled) to your computer with USB (you will need to do this just once per session)
- Tools -> Android -> ADB WIFI -> ADB USB TO WIFI (Or use the key combination mentioned. For MacOS: ctrl + shift + w)
Note: If it did not work:
- Your wifi router firewall may be blocking the connection.
- ABD may not be installed on your computer.
On my system it went like this:
On my Android device in my Linux shell, a simple "ifconfig" did not give me my IP address. I had to type:
to get my IP address. (I knew eth0 was configured because I saw it in my dmesg.) Then I did the :
setprop service.adb.tcp.port -1
Then on my Win7 box (the one running Eclipse 3.7.1). I opened a command prompt to
without running as admin. Then I did a
adb connect 12.345.678.90
I never put a port. If I did a
adb tcpip 5555
it said it couldn't find the device then nothing appeared in my "adb devices" list. I.e. it only works if I DON'T do the tcpip command above.
I can do an "adb shell" and mess with my Android Device. But my Android Device does not appear in my Run->Run Configurations->Target tab right now. On the other hand, if I keep the Target Tab set to automatic. Then when I run my app via Run->Run it does run on my Android device even though my Android device is not even listed as one of my targets.
You Need to do following things:
- First, Add ADB to your environment path.
- From your CLI type this command adb connect YOUR_DEVICE_IP:PORT_NUMBER (example adb connect 192.168.100.100:5555)
Here's an extension to Brian's answer using Bluetooth:
On Linux, use Blueman to share PC internet with your device via Bluetooth:
$ sudo apt-get install blueman $ blueman-manager Pair them: Search devices after enabling Bluetooth on your phone and making it visible $ blueman-services Network > [X] Network Access Point (NAP) Your Phone > Settings > Bluetooth > Paired Device > [X] Internet access
Use the Bluetooth network for ADB commands:
$ adb tcpip 5555 $ adb connect $(adb shell ip -f inet addr show bt-pan | egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n1):5555
Once done to return to USB mode:
$ adb disconnect $ adb usb
I just followed following steps and it started working, so that i can connect to my android device.
Step 1: Open the terminal Window in Android Devices and execute the following command.
- su -- To switch to super user.
- setprop service.adb.tcp.port 5555 - To specify the tcp Port - 5555 is the port number here
- stop adbd - To stop the adbb service.
- start adbd - To start adbd service.
Step 2: Through ADB, Execute the bellow command.(From the path where ADB is configured)
adb connect 10.10.10.50:5555 - Here 10.10.10.50 is the IP address of the android device and 5555 is the port number.
I find the other answers confusing. Far simpler to use adbWireless:
Simply install an app on your phone to toggle debugging over wifi, install an eclipse plug-in and you're done.
I needed to get both USB and TCPIP working for ADB (don't ask), so I did the following (using directions others have posted from xda-developers)
su #Set the port number for adbd setprop service.adb.tcp.port 5555 #Run the adbd daemon *again* instead of doing stop/start, so there #are two instances of adbd running. adbd & #Set the port back to USB, so the next time ADB is started it's #on USB again. setprop service.adb.tcp.port -1 exit
First you must connect your device via USB
Then connect your device to WIFI and get the IP address. While still connect via usb type this in command line or via Android Studio Terminal
adb tcpip 5555 adb connect <device IP>:5555
You will see these messages:
restarting in TCP mode port: 5555 connected to 188.8.131.52:5555
Now remove the USB cable and you will still see your logcat as normal
One additional note (learned the hard way): You should not have your company VPN-connection active at the same time...