desertboat
desertboat

Reputation: 155

adb wifi often go offline, how to keep adb online?

I'm using Android tablet communicating with a USB device through USB port, the tablet only has one usb port, so I use adb wifi as my debug tool. However, when I connect adb through WIFI, the connection won't keep long(only a few minutes us usually), how to keep the adb wifi connection online all the time? Another question, is it possible to use USB HUB to connect the tablet with both USB flash-drive and my computer, and keep adb running? Many thanks!!!

Upvotes: 10

Views: 17047

Answers (7)

Shahan Ahmed
Shahan Ahmed

Reputation: 41

So, I'm using Scrcpy and Adb to wirelessly connect to my Phone(for developing Flutter Apps) and since the screen wasn't staying awake even by Scrcpy --stay-awake command.

I had to change Lock Settings=>Lock Screen => Sleep, and settings to Never Sleep.

Upvotes: 0

Saeed Noledan
Saeed Noledan

Reputation: 1

I tried many ways but this one worked out for me: force the display on and of in a loop would keep the device online

adb shell input keyevent 224
timeout 2
adb shell input keyevent 26
timeout 58

this turns the display on every minute for 2 seconds

Upvotes: 0

Onur OKYAY
Onur OKYAY

Reputation: 321

After lots of unsuccessful attempts,I have noticed that turning Allow ADB debugging in charge only mode specification on , solved the problem . It makes the device online and accessable over wifi to ADB. You can find it under Developer options section.

Upvotes: 9

Oliver
Oliver

Reputation: 29571

When connection is lost and adb devices shows device is offline, like this:

prompt> adb devices
List of devices attached
192.168.1.1:5555     offline

then adb disconnect IP followed by adb connect IP will often work:

prompt> adb disconnect 192.168.1.1
disconnected 192.168.1.1
prompt> adb devices
List of devices attached
prompt> adb connect 192.168.1.1
connected to 192.168.1.1
prompt> adb devices
List of devices attached
192.168.1.1:5555     device

Upvotes: 2

Jisu Hong
Jisu Hong

Reputation: 724

Here is what I found out from researching everywhere and developing on my own for more than a week.

Q1. adb service often crashes if it is not doing any executions for a long long time.

A1. calling adb commands time to time keeps adb server online.

Q2. wifi connected device sometimes disconnect.

A2. Before you check your wifi on the connected device, check the wifi that your ADB server is running on. Ping to google and if it is well connected, ping to the device.
Wireless can disconnect on its own and even wired connection is sometimes disconnected. so calling "adb connect ..." when the device is not already connected is necessary. You could do this easily by saving "adb devices > device.txt" and query out whether your expected wifi is on the list. If not, connect again..(do this in another thread).

Q3. wifi connected device is sometimes offline.

A3. This is because by TCP/IP connection your ADB server is now on Time_Wait stance. The last connection was interrupted that the next connection is now offline because the last connection is not completely shut down. You can either manually disconnect/connect your device's wifi or restart TCPIP connection by ex) "adb tcpip 5555" If you want to do this automatically, you are going to have to disconnect/connect your device's wifi programmatically.

Leave any other questions and I can answer on the comments.

Upvotes: 5

Berkay92
Berkay92

Reputation: 586

Use adb over wi-fi without any third-party apps. Follow the steps.

  1. Connect device via USB

  2. Open your terminal and check your device is listed with adb devices command

  3. Type adb tcpip 5555 and enter (or use another port instead of 5555)

  4. Plug out your USB cable. You don't need it anymore.

  5. Take your Android phone and go Settings/About/Status

  6. Check the IP address part. Let's say your IP address is 192.168.x.y

  7. In your terminal, write the command adb connect 192.168.x.y

  8. Now, you have connected your device via wi-fi.

  9. You can see your device in adb devices

  10. Enjoy it! :)

Upvotes: 1

Shaishav
Shaishav

Reputation: 5312

This seems like an issue with your wifi. As a precaution, just keep the terminal open and whenever you need to test just press the 'UP arrow' key to get to previously ran adb connect "<ip>" command.

Upvotes: 0

Related Questions