18

For some reasons, my phone does not work anymore with cable.

I saw on the Internet that it is possible to connect adb to the via Wifi, however I tried it and I get this:

adb devices
List of devices attached
192.168.1.2:5555        offline

I search this on Google and it seems that it is related to Android 4.2.2. And indeed, my device is running Android 4.2.2.

I didn't find any answers on Google for my problem since it is always with a cable, mine is on Wifi...

Any idea how to solve this?

vital
  • 1,198
  • 2
  • 12
  • 27

24 Answers24

36

For me the complete steps that worked were :

  • Settings -> Developer options -> Revoke USB debugging authorizations (clear the list of authorized PCs).

  • Set USB Debugging OFF.

  • In Terminal write : adb kill-server

  • Then : adb start-server

  • Then : adb connect xx.xx.xx.xx:5555 (the devices ip), it should say unable to connect.

  • Now turn ON USB debugging again and type the adb connect xx.xx.xx.xx:5555 again.

    It should now ask for authorization and you are back online without needing to connect cable to USB, only wifi used.

Gery
  • 465
  • 4
  • 6
  • 2
    The key for me was to turn off usb debugging, then turn it back on. This seems necessary if switching between computers – Nick Jan 28 '17 at 22:46
11

run adb kill-server, then try to connect wirelessly again. It worked for me.

vitaly
  • 443
  • 1
  • 5
  • 7
  • thanks!! it help for me to trigger the message on the phone "Allow USB debugging?" that was in "offline" mode in adb devices, and in Android-Studio – ofir_aghai Dec 31 '15 at 17:49
7

I could not find exact solution for this problem too. Best way worked for me was disconnecting device from wifi, then try to connect while device is not connected to Wifi like:

adb connect 192.168.55.3:5555

this causes adb waiting for connection. immediately connect device to wifi and adb will detect device and connect again. hope this helps.

Ali Arasteh
  • 91
  • 2
  • 4
5

Disconnect adb over wifi, connect your phone with a USB-cable to your pc. It will ask you on your phone is you want to allow the connection. Tick always allow. You will only get this when you connect with USB and have to do this only once, you can use over wifi afterwards. Don't get the pop-up? Try the answers on google over a cable, since you need to do this first.

P1nGu1n
  • 586
  • 8
  • 23
  • I can't do that... The reason I want to connect over wifi is because my phone USB plug is broken down, it cannot be used anymore. – vital Jul 24 '13 at 19:15
  • That was the only solution I found to trigger the pop-up over wifi for me unfortunately – P1nGu1n Jul 28 '13 at 10:40
4

It seems you want authenticate adb over wifi.If you had your device rooted,you can try this way.

  • Copy ~/.android/adb_key.pub to your android device,and rename it to adb_keys

  • Move it to your /data/misc/adb/

  • Reboot your android,then reconnect over wifi.

xcodebuild
  • 911
  • 7
  • 15
  • if you have root access, you need no reboot, just do: adb shell su 0 setprop ctl.restart adbd – diyism Mar 21 '17 at 05:04
  • With this I can allow adb connect to VirtualBox android-x86 CM13. Usual connect do not show any prompt on android device. – Enyby Jul 18 '17 at 23:29
3

For the first time in debug mode, you need to Authorize your phone with the PC, and that requires the USB cable. After that you can use Debug over WIFI.

If you want to force your phone to show the Authorization message box, simply delete the below file.

/data/misc/adb/adb_key
3
  1. In android studio go to Preferences->Plugins
  2. Download and install this plugin ADB WIFI Connect , restart Android Studio
  3. Connect phone via USB
  4. In android terminal use command: adb devicesyou should get visible device connected via USB:
List of devices attached

988a57334e57365058      device
  1. Click on plugin icon in android studio AndroidWiFiADB
  2. If phone get connected properly via WiFI, you see in event log:

12:41 Android WiFi ADB: Device 'ModelOfYourPhone' connected.

  1. In android terminal use command: adb devices use should get
List of devices attached
988a57334e57365058      device
192.168.60.101:5555     device
  1. Disconnect USB cable and re-check again adb devices, should remain only device connected via wifi:
List of devices attached
192.168.60.101:5555     device
ivanko
  • 433
  • 5
  • 6
2

Try disconnecting your device with:

abd disconnect <IP/TCP>:<port>

Then restart the WiFi connection of your device, and reconnect your device with:

abd connect <IP/TCP>:<port>

That may fix it; it worked for me.

reuben
  • 3,280
  • 21
  • 28
Parimal
  • 21
  • 2
2

Make sure that pc is authorized in the device by going to Developer options -> Revoke USB debugging authorisations and then trying to connect via USB. After accepting the PC, disconnect the cable and connect through wifi.

adb kill-server
adb run-server
adb connect IP:5555

Although in my case, when I tried to connect it failed at first and second try it said already connected.

I disconnected from the device and connected again and it solved.

adb disconnect ip:5555
adb connect ip:5555
Mahdi-Malv
  • 7,231
  • 1
  • 26
  • 65
1

My solution steps:

  1. Turn Off WiFi and Turn it back On again.
  2. Settings -> Developer options -> Revoke USB debugging authorizations.
  3. Settings -> Developer options -> Turn Off ADB over network and turn it back On again.
  4. adb kill-server
  5. adb start-server
  6. adb connect xx.xx.xx.xx:5555

Note: Step 3 was the key for me. don't forget it.

Ayub
  • 1,705
  • 21
  • 27
1

For me, the important part turned out to be the following line adb tcpip 5555 together with using the port in the IP of my phone like so: adb connect 192.168.1.87:5555 (only using one of them, did not work, i.e: writing the second alone didn't work, writing the first and then excluding the port in the IP also didn't work). The adb tcpip 5555 line is not mentioned anywhere here. So, for me, the PORT needed to be both manually set and used in the connect line!

These are the events of my command line in Windows PowerShell Admin to demonstrate (Wifi on and debug mode on and confirmed permission when the popup came):

notice that the connection first failed, then it said it was connected which is weird behavior to begin with (no matter what, it always failed once and "succeeded" once), and in both instances, the device showed as offline. The disconnect commands also confirm that its 110% offline

PS C:\WINDOWS\system32> adb kill-server
PS C:\WINDOWS\system32> adb start-server
error: protocol fault (couldn't read status): Connection reset by peer
PS C:\WINDOWS\system32> adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
failed to connect to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece        device
192.168.1.87:5555       offline

PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
already connected to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece        device
192.168.1.87:5555       offline

PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb tcpip 5555
restarting in TCP mode port: 5555
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
connected to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece        device
192.168.1.87:5555       device

As soon as I added the adb tcpip 5555 command and it restarted in TCP mode port: 5555 the adb connect 192.168.1.87:5555 command worked!

1

In simple cases it will start after Enabling USB debugging

For complexities you need to delete the

adbkey

file from

C/.android and then running following commands in command prompt

adb kill-server 
adb start-server 
adb devices
Pravin Yadav
  • 211
  • 2
  • 9
0

Note that wireless adb connectivity in Android 6.0.0 is broken. Updating to 6.0.1 fixes the issue.

https://stackoverflow.com/a/34530543/1123355

Community
  • 1
  • 1
Elad Nava
  • 6,524
  • 2
  • 36
  • 59
0

In Windows, if you are using system-wide proxy software like Proxifier, you need to add adb.exe to the ingore list or direct-mode list. In my case, using Proxifier will make adb able to connect to any IP address even when the phone is not connected to the WiFi, and this leads to device offline.

Jiaqi Liu
  • 555
  • 1
  • 4
  • 15
0

I know its late to answer but I believe this is the exact answer:

go to WIFI setting on your device and "set a new IP" in your network IP range an reconnect.

Nobody8
  • 552
  • 5
  • 13
0

Conflicting ADB connections can cause this issue as well:

Windows Host with Docker to Hyper-V Android x86 emulator

I didn't see this answer here yet so for those attempting something similar, the issue I had was that the local Windows Host ADB process had already acquired the adb connection during start up (adb server start).

By simply running: adb disconnect <Device/Android x86 Hyper-V ip>:5555 on host machine

Running adb connect <Device/Android x86 Hyper-V ip>:5555 on the Docker container was able to successfully acquire the remote device (aka Android x86 Hyper-V)

IMPORTANT!!! Until you disconnect Docker (or whatever), your host machine (or any others) will not be able to connect, apparently only one ADB connection at a time is allowed.

I didn't need to do anything else listed above. Hope this helps others.

James Nelson
  • 703
  • 8
  • 12
0

Just turn off your Proxifier or something else like this.

Socks5 works fine

FelixSFD
  • 5,456
  • 10
  • 40
  • 106
Jhonylulu
  • 1
  • 1
0

I have this problem just now. Note that my case is special, the usb has been disabled for security concerns. Reboot not working. This is not ip problem since ping is working and nmap shows 5555 port is open. Also since I will not able to connect if port is wrong, so nothing to do with port.

There are 4 reasons:

  1. Because another pc in the local network already connected, so the other guy have to adb disconnect first, then I can do adb disconnect and adb connect <ip>, since only one person can connect at the same time.

  2. A hotspot ssid name might consists of multiple bssids in (especially you're in office) local network, so you need to ensure your pc try all the hotspot bssids which match the android connected hotspot bssid. Note that I noticed it's not always the case (Now I tried different bssids still success), but it did solved before.

  3. Ensure the port 5555 is open correctly. Even though there are many ways, but you can download this app to open port 5555.

  4. And I just encounter a weird case, client A connect just fine. But then client B turn on wifi and attempt to connect but failed. Then this failure causes original client A no longer able to connect. Reboot device/adb disconnect/adb kill-server doesn't help, and confirmed the ip is same(tested by turn off/on device and observe the ping). I make a joke about client B wifi still turn on may interfere the device wifi. Then I realized Client B disconnect/kill-server is not enough, client B also need turn off wifi to make client A connect. And it did.

Fruit
  • 6,309
  • 3
  • 42
  • 57
0

Watever! I'm always using these steps to connect ADB Wifi with android studio

STEP-1: 1. Go to Android studio->Settings-> Plugins -> Search ADB WIFI 2. Install the pluging and restart android studio

STEP-2: 1. Find the location of SDK Manager For ex for my computer enter image description here

  1. Copy the whole location
  2. Now open Terminal in Android studio itself( This will show in right bottom corner).
  3. type cd YOUR_SDK_LOCATION
  4. type cd platform-tools
  5. Now type adb tcpip 5555

FOR NEXT STEP YOU MUST CONNECT YOUR MOBILE AND LAPTOP WITH SAME WIFI

  1. type adb connect 192.168.6.100:5555 in terminal (Here 192.168.6.100 is your mobile IP Address)

now the message will show like this 'connected to 192. 168.6.100:5555'

STEP -3 : 1.Go to Android studio->Tools->ADB WIFI-> ADB Restart 1.Go to Android studio->Tools->ADB WIFI-> ADB USB to WIFI

Like below

enter image description here

That's it .

0

In My case my wifi network is not same thats why i am not getting connected with the device.

There is very easy and helpful plugin for this purpose Android Wifi ADB

How to Connect using plugin:

  1. connect device using cable
  2. click on Android wifi adb icon
  3. disconnect your USB connection now your device is connected over wifi.

Enjoy Happy debugging.

0
  1. adb reconnect offline
  2. adb connect [ip]:[port] (for exemple adb connect 192.168.8.100:44
0

While all tips with killing ADB server helped me many times, now I got the message:

cannot connect to <IP>:<port>: No connection could be made because the target machine actively refused it. (10061)

It was possible to attach the device only while it was connected with USB, and after disconnecting cable it appeared as offline at the attached devices list.

I have just solved my problem by changing the USB configuration:

Developer options > Select USB Configuration: MTP (Media Transfer Protocol)

PTP (Picture Transfer Protocol) works as well.

Screenshot

I hope it will help.

Community
  • 1
  • 1
0

I solve this problem for huawei P10. its about phone's developer settings => find usb developer settings, and under usb developer setting there is a "adb debugging in charging mode..." enable it. My problem solved with this way. Hope yours too....

0

Try,
adb disconnect <your_ip_address>:port_number or adb disconnect

eg.
adb disconnect 192.168.1.2:5555

Or
adb disconnect

The difference is that first one will disconnect only the required device, the second one will disconnect all the devices.

The benefit of using this command is that you don't have to kill and restart the server. Killing and restarting the server requires your device to be plugged in to your computer which is most irritating process.

Juned Khan Momin
  • 2,028
  • 10
  • 30