61

Is it possible to show the adb logcat for a tcpip device in Android Studio? I am writing a application that utilizes the USB port and I cannot use it for adb usb.

Currently, I am using the following instruction to view the logcat in Command Prompt, but it would be nice if this was integrated into AS: http://developer.android.com/tools/help/adb.html#wireless

nsandersen
  • 896
  • 2
  • 16
  • 41
Ryan R
  • 8,342
  • 15
  • 84
  • 111
  • Download a script to do that just provide your IP and done [wireless.bat](http://stackoverflow.com/a/38415096/6598402) – Astik Sachan Jul 16 '16 at 20:05

5 Answers5

101

After some testing Android Studio already supports this. You just need perform the following ADB commands, and now you can see the logcat and even wirelessly load your application. No USB cable needed!

From: http://developer.android.com/tools/help/adb.html#wireless

$ adb tcpip 5555
restarting in TCP mode port: 5555

Finding out IP address of Android device prior to running Android Oreo:

Settings -> About tablet -> Status -> IP address. Remember the IP address, of the form #.#.#.#.

Finding out IP address of Android device running Android Oreo

Settings -> Wi-Fi -> -> IP address

Connect adb host to device:

$ adb connect #.#.#.#
connected to #.#.#.#:5555
Dean Meehan
  • 2,511
  • 22
  • 36
Ryan R
  • 8,342
  • 15
  • 84
  • 111
  • 1
    Also checkout: Automating ADB over Wi-Fi for multiple devices http://androiddevcorner.blogspot.ca/2014/08/automating-adb-over-wi-fi-for-multiple.html – Ryan R Aug 19 '14 at 20:49
  • 10
    what worked for me was directly `adb connect ip.address.comes.here:5555` – EpicPandaForce May 21 '15 at 08:20
  • 1
    Another place where IP can be found: settings->WIFI->click on wireless you connected to. IP will be in the bottom – kandi Aug 11 '15 at 09:37
  • i got this error..."unable to connect to 192.168.1.2:5555: Connection refused" – John Apr 10 '16 at 07:03
  • 'Android Wifi adb' plugin is a good way to achieve this. link: https://github.com/pedrovgs/AndroidWiFiADB – Sk Saad Al Mahmud Sep 06 '16 at 10:10
  • The gotcha is that you have to do this from within Android Studio's terminal or custom external command. Simply doing this in a terminal window then saying debug in Studio didn't work at least for me. – Laine Mikael Nov 01 '16 at 18:24
  • 1
    @John @Patric you need to close all the soft emulators, then connect your phone via usb (with usb debugging enabled) and _then_ execute `adb tcpip 5555`. After that it will work. – Aspiring Dev Feb 28 '17 at 20:45
  • Is there a way to keep this enabled between restarts? In my case it doesn't remember the wireless connection after shutting down my machine. This isn't that useful if I have to connect my device via USB each time in order to setup the wireless connection. Connecting it via usb is exactly what I'm trying to avoid :/ – Aspiring Dev Mar 01 '17 at 13:43
  • @rpgmaker Not as far as I know. – Ryan R Mar 02 '17 at 23:27
  • Socket also available under developer options where you switch on "ADB over network" on Android 8.1 at least. Useful when debugging power state responses when removing and plugging in the cable! And when the USB connection goes "OFFLINE" within a few seconds. – nsandersen Apr 04 '19 at 10:04
42

In android studio, you can create a one click solution.

  1. Go to File > Settings > Tools > External Tools
  2. Create a tool with the following settings, making sure to replace the path to adb with your path

enter image description here

  1. Press Ok and save the tool
  2. In Android studio, click Tools > External Tools > Android Over Wifi

  3. A prompt similar to this should pop up and you can type your phone's IP address here. (You can get this address from your phone when you enable ADB over network)

enter image description here

  1. After you enter the information required, you should now be connected. Congratz and enjoy wireless debugging :).

EDIT 2019!!

Another great answer was posted on this thread but was deleted, which mentioned the existence of an IntelliJ/AndStud plugin that automates the above process. I have not tested the plugin but here is the github page for it. Gl

smac89
  • 39,374
  • 15
  • 132
  • 179
  • It says access denied. I am using unrooted phone is it required to have a rooted phone or will it work on every phone ? – Faraz Ahmed Dec 26 '16 at 07:41
  • 1
    @FarazAhmed, Setting it up on Android Studio should work regardless of the existence of a phone. Setting it up on your phone usually involves going to "Developer tools", and selecting "Enable adb over network" option or something similar. You might have to look up how to do this for your specific phone type – smac89 Dec 27 '16 at 07:09
  • Thank you for your comment, I was committing a mistake in ADB path and now problem is solved. – Faraz Ahmed Dec 27 '16 at 07:36
  • Is there a way to automate this ? (for example, connect to a given IP whenever I launch AS or when run a given configuration) – Sébastien Feb 13 '17 at 15:33
  • 2
    The only proper answer. Not a "here's this magic command line so you have to type a command line every time you want to debug. Oh, and sudo, fo some reason." – MoDu Jul 14 '17 at 09:36
  • 1
    @smac89 Thank you. Very convenient. It should be noted that the device's USB-connected server must be killed first. – iSofia Sep 20 '17 at 06:46
  • 1
    You can even simplify this by using a macro instead of the full path: `$ModuleSdkPath$/platform-tools/adb` – Morty Mar 09 '18 at 15:56
  • If you set a static IP to your device in router. You can remove the prompt. Also don't forget to use the adb in `platform-tools/adb`. – Naveen Niraula Jul 27 '19 at 07:33
24

It's simple, open Terminal inside Android Studio and then type

adb connect "your IP address"

That's all. Remember that to use adb wireless your device must be root

enter image description here

GMG
  • 1,498
  • 14
  • 20
  • Is root a requirement? – Ryan R Apr 10 '15 at 15:54
  • 1
    without root the Android device can only use adb over USB, if the Android device is rooted you can use any app that enables adb over tcp. The limit is the device not Android Studuio – GMG Apr 10 '15 at 16:09
  • 8
    Root is not required according to [this SO answer](http://stackoverflow.com/a/10236938/134761). Works for me. – angularsen Sep 23 '15 at 18:20
  • 2
    Second the above comment. No root here, but ADB over TCP works for me. – Tony Shepherd Jan 13 '16 at 04:33
  • 2
    This is the only method that worked for me. No root required. – Marco Altran Feb 25 '16 at 15:06
  • Root it not required guys, please see http://stackoverflow.com/a/24703483/3792198 or https://developer.android.com/studio/command-line/adb.html#wireless – Thiago May 24 '16 at 08:10
  • Root is not required if the manufacturer has left open the ability to connect over wifi, but for security reasons is difficult to find a device that has adb enabled on wifi, so if you don't have root you can't normally connect in WiFi. Try yourself with samsung for example. Imagine a device that has adb enabled in WiFi, it can be reached from ever place in the world, very dangerous for security. – GMG May 24 '16 at 08:16
  • Seems with cable you don't need root to enable adb over tcp according to the link above. But if you forget to bring a cable to office you still can enable it without cable on phone using such apps, only if you have root access. – Meow Cat 2012 Apr 13 '18 at 07:24
7

I was given an Gigabyte Box with Android OS on it. The box had a USB and Ethernet port. These are instructions for getting my Windows 7 PC to connect with Android OS in order to see Debug Output on Android Studio.

How to use the USB port to debug:

1) Open Command Prompt

2) Go to wherever you stored adb.exe file

3) Type in “adb connect (Your Gateway’s IP Address)”. For example, "adb connect 192.168.1.94".

The IP address of the Android device can be found in Settings icon-> About tablet -> Status ->IP Address

enter image description here

If you’re in the adb.exe directory, other adb commands include:

1) adb devices= Finds all devices currently connected to your computer.

2) adb kill-server= Disconnects the devices


Ethernet Port to Debug:

http://www.techrepublic.com/blog/software-engineer/debug-android-applications-over-ethernet/

1) Open a command prompt and navigate to the directory where your copy of ADB.exe lives.

2) Type "adb tcpip 5555" and press Enter.

3) Type "adb connect 1.1.1.1:5555", replacing the 1.1.1.1 with your phone or tablet's IP address.

enter image description here


Gene
  • 10,819
  • 1
  • 66
  • 58
3

adb devices

adb tcpip 5555

adb connect 192.168.4.23

Unplug you device and run the adb connect 192.128.4.23 command again

For further details Check this article