100

I want to debug Android APPs on my phone (LG nexus 4). I'm travelling and I forgot my USB cable. When I work at home I can do it just connecting the USB cable and executing the command 'adb tcpip 5555'. Then I can unplug the USB cable and connect via 'adb connect IP'.

But now I cannot execute the first command because I don't have a cable. I don't understand why I have to do it every time, since I already execute the 'adb tcpip' command before.

What I tried now:

I installed a terminal application on my Android and tried to execute that command there, but I received a "device not found" error. Maybe he cannot see himself...

I search for any reasonable option in "Android Development Options" and enabled everything seemed to have relation with Wifi. But nothing helped.

I search StackOverflow, but all answers I found involving connect via USB cable before. Is there I way to do this connection without the need of a cable at all?

Some info: My Nexus 4 isn't rooted. The android version is 5.1.1.

alexpfx
  • 6,412
  • 12
  • 52
  • 88
  • I understand you're trying to find a technical solution for it, but, isn't easier to just buy a cable? – Budius Jul 09 '15 at 20:46
  • 1
    it would be easier, but where I am there is no usb cables being sold around. – alexpfx Jul 09 '15 at 20:50
  • 1
    When you get home, buy a bunch of micro USB cables on eBay or elsewhere. Scatter them liberally throughout your luggage. :-) With respect to your problem, though, AFAIK only certain devices (e.g., Fire TV) are set up to do adb-over-TCP/IP on a full-time basis, for developers that opt into this. I am not aware of any workaround for other devices. "I don't understand why I have to do it every time" -- security, I imagine. – CommonsWare Jul 09 '15 at 21:03
  • I have a bunch of this cables at home, but it is not so useful if I forget them =). So if there is no way I will go to the town tomorrow and try to find a place that sells it. :) – alexpfx Jul 09 '15 at 21:12
  • see my answer, it might help; I understand why ur trying to find tech solution for this but I dont understand why on earth they didnt update adb so we can use it remotely automatically without setup commands.. I made shell script for that so now I need only to type 1 command to connect but still it is so annoying and sometimes it disconnect itself. Its 2015, 2016 soon, new notebooks doesnt even have LAN ports anymore and wireless charging is behind the corner. Google wakey, wakey – Srneczek Oct 24 '15 at 13:26
  • Good question but wrong marked answer. SO must do something about this type of questions and selected answers. – Mehdi Dehghani Apr 17 '18 at 06:33
  • @MehdiDehghani What's the correct answer in your opinion? – alexpfx Apr 17 '18 at 09:40
  • 1
    None of them didn't answer to your question, there is no way to use WiFi without USB cable in not-rooted devices. the marked answer works for you? – Mehdi Dehghani Apr 17 '18 at 10:15
  • @MehdiDehghani I didn't try. I give up and a day later I bought a usb cable. at that time the answer seemed the most plausible solution. – alexpfx Apr 17 '18 at 10:59
  • Thanks for the explanation. how you deleted the marked answer btw? :D – Mehdi Dehghani Apr 17 '18 at 11:14
  • 1
    I didn't... I just unmark it :) – alexpfx Apr 17 '18 at 11:18
  • 9
    For those saying "just buy a cable", my USB port no longer responds (I charge wireless), I do not have that option, but still want to debug. Phone is fine apart from that, repairing is a bit expensive for just a USB port :) – Martijn Jun 19 '18 at 19:35
  • 1
    @Martijn Also in the jungle, where I was, there was no option to buy a cable. :) – alexpfx Jun 19 '18 at 19:56
  • ALSO for those saying "buy a cable" there are other reasons to want to forgo using USB, such as sending conifg you can only set up over adb which the device periodically forgets. In that case, it's just a single command, but if it could be done over WiFi it could be automated. And some of us are locked out of being able to root our phones to do it as root. – Michael May 13 '20 at 03:24
  • There's plenty of "as far as I know" and "it seems" around the impossibility of non-rooted adb with no cable at any time, but can anyone find anything in the docs or specs or anywhere else that it is expressly forbidden, even without an explanation? – Ger May 16 '20 at 18:17
  • 1
    Android 11+ has a developer option Wireless Debugging. Then use adb pair ipaddr:port https://developer.android.com/studio/command-line/adb#connect-to-a-device-over-wi-fi-android-11+ – curlyhairedgenius Nov 04 '21 at 03:43
  • **TL;DR:** Google actively and deliberately made this not possible. You will not find a solution below. **The only correct answer is to not buy any product over which you don’t have full control.** As such devices are crimes that are strangely still “legal”. Prevent such organized crime (Yes, organized crime. I has to be said.), and buy one of the many phones where the bootloader is not locked. E.g. a Fairpone. – Evi1M4chine Jan 13 '22 at 06:28

7 Answers7

31

The question is about a non rooted device but if it is rooted the simplest way would be to:

From the terminal on your phone, do this:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

See this answer for full details.

Simson
  • 3,373
  • 2
  • 24
  • 38
Buddy
  • 10,874
  • 5
  • 41
  • 58
  • 62
    Note that the question states that the device is not rooted, so `su` will not be available. – CommonsWare Jul 09 '15 at 20:59
  • 3
    I cannot execute the su command. I received "command not found". Maybe cause it is not rooted? I execute the setprop command without su but I received "cannot set property". – alexpfx Jul 09 '15 at 21:01
  • 2
    Sorry I missed the "not rooted" part... – Buddy Jul 09 '15 at 21:08
  • You don't need su to make it work on all of my devices [around 10], hopefully this is a standard thing. – Krystian Mar 24 '18 at 11:52
  • 1
    Question states "for not rooted phones", this answer doesn't meet that criteria. Why is it the most upvoted answer? – Abushawish May 18 '18 at 14:59
  • This answer should be removed as it is clearly not valid, totally misses the point –  Sep 08 '19 at 20:38
  • 7
    This is a good answer for readers brought here by search engines, who also missed the non rooted part of the question – Simson Oct 03 '19 at 02:01
  • but it didn't work for me, `adb connect 192.168.1.105` says `unable to connect to 192.168.1.105:5555 connection refused` – Necktwi Feb 01 '20 at 09:00
  • This definitely doesn't answer the question that was asked, but is exactly what I was searching for! Needed the command to set up a start-up script. Many thanks!! – Jason Waltz Aug 14 '20 at 07:48
  • 1
    Just figured you can also set setprop persist to make the change permanent --> setprop persist.adb.tcp.port 5555 – Jason Waltz Aug 14 '20 at 08:13
  • Thank you. It is very hard to find a solution for rooted device – Amos Wong Sep 23 '20 at 15:43
  • @JasonWaltz is it safe to set it permanently? it's kinda open port, if I understand it right? – JulyMorning Jun 11 '21 at 13:54
  • For a non-rooted device you can now use pairing code: https://android.gadgethacks.com/how-to/set-up-wireless-debugging-android-11-send-adb-commands-without-usb-cable-0302898/ – Joseph Siefers Dec 19 '22 at 18:58
25

For your question

Adb over wireless without USB cable at all for not rooted phones.

Old Answer:

You need to connect your device to your computer via USB cable. Make sure USB debugging is working. You can check if it shows up when running adb devices.

Open cmd in ...\AppData\Local\Android\sdk\platform-tools

Step1: Run adb devices

Ex: C:\pathToSDK\platform-tools>adb devices

You can check if it shows up when running adb devices.

Step2: Run adb tcpip 5555

Ex: C:\pathToSDK\platform-tools>adb tcpip 5555

Disconnect your device (remove the USB cable).

Step3: Go to the Settings -> About phone -> Status to view the IP address of your phone.

Step4: Run adb connect <IP address of your device>:5555

Ex: C:\pathToSDK\platform-tools>adb connect 192.168.0.2

Step5: Run adb devices again, you should see your device.

Now you can execute adb commands or use your favorite IDE for android development - wireless!

Now you might ask, what do I have to do when I move into a different workspace and change WiFi networks? You do not have to repeat steps 1 to 3 (these set your phone into WiFi-debug mode). You do have to connect to your phone again by executing steps 4 to 6.

Unfortunately, the android phones lose the WiFi-debug mode when restarting. Thus, if your battery died, you have to start over. Otherwise, if you keep an eye on your battery and do not restart your phone, you can live without a cable for weeks!

See here for more

Ref: https://futurestud.io/tutorials/how-to-debug-your-android-app-over-wifi-without-root

UPDATE 1:

If you set C:\pathToSDK\platform-tools this path in Environment variables then there is no need to repeat all steps, you can simply use only Step 4 that's it, it will connect to your device.

To set a path: My Computer-> Right click--> properties -> Advanced system settings -> Environment variables -> edit path in System variables -> paste the platform-tools path in variable value -> ok -> ok -> ok

UPDATE 2:

  • Go to the android terminal
  • adb tcpip 5555
  • adb connect your_ip_address

We can do it without a USB cable at all in the following ways.

NEW UPDATE 1: (Latest Answer without using USB cable at all)

Note: It will work only when your laptop and mobile should connect to the same WiFi.

  • Step 1: In Android studio choose "Pair Devices Using Wi-Fi" from the Device Connections dropdown.

enter image description here

  • Step 2: In Mobile go to settings and search for "Pair using QR code" and scan the QR code

enter image description here

NEW UPDATE 2: (Latest Answer without using USB cable at all)

Note: It will work only when your laptop and mobile should connect to the same WiFi.

Go to developer options from the mobile settings and enable Wireless Debugging

That's it!

Shailendra Madda
  • 20,649
  • 15
  • 100
  • 138
20

Had same issue, however I'm using Macbook Pro (2016) which has USB-c only and I forgot my adapter at home.

Since unable to run adb at all on my development machine, I found a different approach.

Connecting phone with USB cable to another computer (in same WiFi) and enable run adb tcpip from there.

Master-machine : computer where development goes on, with only USB-C connectors

Slave-machine: another computer with USB and in same WiFi

Steps:

  1. Connect the phone to a different computer (slave-machine)
  2. Run adb usb && adb tcpip 5555 from there
  3. On master machine

    deko$: adb devices
    List of devices attached
    
    deko$: adb connect 10.0.20.153:5555
    connected to 10.0.20.153:5555
    
  4. Now Android Studio or Xamarin can install and run app on the phone


Sidenote:

I also tested Bluetooth tethering from the Phone to Master-machine and successfully connected to phone. Both Android Studio and Xamarin worked well, however the upload process, from Xamarin was taking long time. But it works.

Deko
  • 1,028
  • 2
  • 15
  • 24
  • 1
    Awesome! Worked like a charm. For beginner, I would like to add that with adb connect ipaddress, here enter your devices ip address. Which can be found under Settings ---> About Phone ---> Status – Kiran Dash Nov 29 '19 at 04:15
  • 60
    question was "without USB" – QkiZ Dec 17 '19 at 01:55
  • 6
    This doesn't solve the main problem, not having a cable. – Cornul11 Mar 25 '20 at 05:06
  • 2
    I never said this is the only solution. But considering upvotes I'd say it sure is an alternative solution. For some it's what works and for other not – Deko Mar 26 '20 at 07:15
  • not an answer to the question – RJE Aug 07 '20 at 19:08
  • This is why SO sucks. "How to do something without USB" Answer: "Step 1. Plug in USB." WTF? And the response "oh, it works for some people" is like telling someone without a lug wrench to grab their lug wrench to change a tire in the middle of nowhere and claiming "oh, some people use lug wrenches, so it's helpful." Just because you answer a _completely different question_ doesn't mean it's helpful for _THIS_ question. Howmever you think you've helped is completely irrelevant on this page. Stop trying to _post hoc_ rationalize. – SO_fix_the_vote_sorting_bug Jul 09 '22 at 03:48
  • @SO_fix_the_vote_sorting_bug, Stackoverflow is not only for *getting the only answer that solves the problem, but rather, getting possible solutions and workarounds for the problem.*. In some situations there might not be a possibility of getting what you need, but getting some solutions that might be useful for someone is better than getting no solution at all. Please note that SO is not only for the person who asked the question, but, it is also for people who are having a similar problem (not the same), so that, others can try what suits best for them. – Junaid Pathan Sep 15 '22 at 22:03
1

This might help:

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 IP" step. (IP is obviously different when you change location.) Or if that doesn't work, reset your adb host: adb kill-server and then start over from the beginning.

Srneczek
  • 2,143
  • 1
  • 22
  • 26
  • after killing server and then reconnecting it works. – Maverick May 14 '16 at 12:11
  • 2
    The question was how to do this once and after that do not use cable anymore even after reboot. Your answer doesn't solve the problem if it does then there's a missing step I believe – user1325696 Nov 10 '19 at 11:53
0

If usb is not working you should checkout debugging over bluetooth (Without Rooting)

http://zcourts.com/2013/07/19/android-debugging-over-bluetooth-without-root/#sthash.hVCLtWSk.dpbs

Peter Morris
  • 20,174
  • 9
  • 81
  • 146
Sahil Bahl
  • 679
  • 3
  • 11
  • 32
    the bluetooth version needs a usb-cable too to setup the device – wutzebaer Jan 06 '16 at 22:34
  • Second link worked for me on non-rooted device... adb tcpip 4455 adb connect 192.168.44.1:4455 – Farzan May 01 '16 at 13:19
  • 1
    I tried the second way, but it seems you need to connect via USB first. When trying without connecting to USB first it says "Connection refused. Unable to connect" – b.lyte Sep 17 '16 at 20:34
-4

type in Windows cmd.exe

    cd %userprofile%\.android
    dir
    copy adbkey.pub adb_keys
    dir

copy the file adb_keys to your phone folder /data/misc/adb. Reboot the phone. RSA Key is now authorized.

from: How to solve ADB device unauthorized in Android ADB host device?

now follow the instructions for adb connect, or use any app for preparing. i prefer ADB over WIFI Widget from Mehdy Bohlool, it works without root.

from: How can I connect to Android with ADB over TCP?

Community
  • 1
  • 1
alecxs
  • 701
  • 8
  • 17
  • 1
    sorry i think it is not possible to access /data partition without root. but i have used this method for broken usb connector without root. first i did a backup from stock recovery, then i extracted adb_keys from backup – alecxs May 22 '18 at 17:49
-10

Connect android phone without using USB cable except XIAOMI PHONES
== MAKE SURE THAT YOUR PHONE HAS USB DEBUGGING ENABLED ==
== IP Address series should NOT be '0' like 192.168.0.10
1. Connect your PC (Laptop) and Android phone to same wifi network.
2. Go to the Android SDK folder > platform-tools and open command prompt by holding the shift key and right clicking on the folder.
3. Type the command "adb tcpip 5555", and hit Enter, sometimes it gives an error but ignore it and go ahead.
4. Type "adb connect [YOUR PHONE IP]". example: "adb connect 192.168.1.34" and hit enter, your phone will be connected to PC.

Community
  • 1
  • 1