Search code examples
debuggingadbwifiandroid-studio-3.0

Android | WiFi adb keeps disconnecting in android studio


It was really strange that adb wifi was disconnecting and debugging via cable is way more unreliable as well as uncomfortable.I did research on internet too. I did try many possible solutions, changing adb drivers, wifi mode and etc. But can't find the problem. It's just keeps disconnecting. I tried to make a loop to keep alive the adb connection.

:loop
adb connect 10.226.170.129:4444
goto loop

But, still didn't work. Even after running this loop infinitely it still disconnected.


Solution

  • WiFi adb is great tool to debug wirelessly. But, there can be many problems to face. So, try this guideline.

    The procedure is below.

    1. connect device to computer
    2. execute this command : adb devices
    3. You should see the device name.

    if not then

    Update adb drivers. click here...

    else

    1. execute this command : adb tcpip 4444

    Here 4444 is a port number which can be replaced with any 4 digit number. 5. remove the device from usb port. 6. execute this command : adb connect IP of your device: port num

    Ip can be anything. It can be found under about section of your device and port number is 4 digit number. for example I will run

    ...
    adb connect 10.226.170.129:4444
    ...
    

    Done it should be connected now.

    if your device is going offline often. That means there are some things to check.

    1. run kill adb-server and then start adb-server. Then follow the procedure.
    2. run adb shell setprop service.adb.tcp.port 4444 before adb tcpip 4444.
    3. Check If networking options are enabled in developer mode. If any wifi related or tethering related options are enabled then disable it.
    4. Some times some devices disconnects adb if screen is locked. So, try to keep display unlocked.
    5. some devices only supports wifi adb in charge only mode. So, try to change it under usb configuration.
    6. Some devices only supports adb in MTP protocol. So, after connecting cable choose MTP or file transfer.
    7. try to run a loop mentioned above.

    Hope this works.

    REFERENCES

    1. adb wifi often go offline, how to keep adb online?
    2. Android ADB device offline, can't issue commands
    3. Adb over wifi killed off after usb disconnect?
    4. ADB over WiFi connection is lost after disconnecting USB
    5. https://android.stackexchange.com/questions/116597/adb-wi-fi-connection-disconnects-when-device-goes-to-sleep-in-moto-g-2014
    6. How can I connect to Android with ADB over TCP?