2

Sometimes when you do adb devices it lists your device , while next moment when you do adb devices it doesn't show my devices.

I am using it for automating a workflow and adb disconnects with my Nexus frequently in between causing it to fail. I am on MAC. I know one solution is to restart adb server or reconnect the device but I cannot use these solutions in between the workflow

Please help

Ido.Co
  • 5,317
  • 6
  • 39
  • 64
user1788294
  • 1,823
  • 4
  • 24
  • 30

5 Answers5

1

I faced similar problem, which got resolved after replacing USB cable.

Sameer
  • 11
  • 1
  • Consider posting this as a comment instead of an answer. After gaining certain number of reputation points you will be able to post comments. – Rahul Bhobe Jul 12 '20 at 19:50
0

use in command prompt call adb kill-server and then call adb devices

I hope its useful to you.

Chandra Sekhar
  • 16,256
  • 10
  • 67
  • 90
dipali
  • 10,966
  • 5
  • 25
  • 51
  • I am aware of this solution but as I said I cannot use them in between my automation workflow. I need a more permanent solution so that my device does not disconnects in between – user1788294 Sep 20 '13 at 06:28
0

You can try running this on the Terminal

adb kill-server

adb start-server

You need to get the Android debug Bridge (ADB) for that.

Razgriz
  • 7,179
  • 17
  • 78
  • 150
0

I don't understand why you can't restart ADB in workflow? Could you provide anything you have donw so we can check. If you're doing an automation/tool that use adb commands, you can get the adb status and depending on that value you can do whatever you need to do. Use

adb wait-for-device

If device couldn't be reached after some time, throw an error.

mgokgoz
  • 186
  • 1
  • 9
  • The automation workflow first checks if device is connected.It does this through adb devices. If device is connected it triggers the automation. After that it wait for a output from the application it launched on device. If the device disconnects in between , then it does not get any output from device and fails. I cannot restart adb in between because to do that I have to make this automation workflow call asynchronous and a synchronous call need to be added to check for devices in a loop , which will make it tedious and unreliable – user1788294 Sep 20 '13 at 06:49
  • Is there any permanent solution so that adb never disconnects my device. – user1788294 Sep 20 '13 at 06:55
  • Can't you have another async call that only checks adb status and with a static variable setup a connection between this two async call. – mgokgoz Sep 20 '13 at 06:59
  • Even if disconnects never happens, user might disconnect his/her device that you would still need a control mechanism – mgokgoz Sep 20 '13 at 07:02
  • I agree with you mate with the solution you suggested and each of checks can be added. But I am looking for a more permanent solution so that my workflow does not frequently results in failure due to "Device not found" issue. Is there any way so that my adb always finds my device and never disconnects it. – user1788294 Sep 20 '13 at 07:08
  • Also to add the device is 24*7 connected to the machine (and will be) and never disconnected manually. Even then I am facing this issue. – user1788294 Sep 20 '13 at 07:10
  • These connection problems is that much. I don't get connection error during adb commands. Few days ago I pushed 3GB without error. And for 1 year use of adb, my devices never disconnected in adb operations – mgokgoz Sep 20 '13 at 07:10
  • Got this issue 2 times out of 46. But it is still an issue and needs to be solved. Don't know what can solve this issue permanently – user1788294 Sep 20 '13 at 07:18
0

If devices are physically connected via USB and adb kill-server does not help to fix the issue, one possibility is that your device is not properly configured for development. Run “Settings”, and make sure that:

  • “Developer options” is ON.
  • “USB debugging” is ON.

(Both need to be ON). Now try again to restart adb server.

In the past I used to have a similar issue: Sometimes adb devices lists my device, but sometimes it does not. When it does not list my device, I have noticed that “USB debugging” has (accidentally) been turned off. Turning it back on has fixed the issue for me. Sure this is only one possibility that may not apply to your case. So it's just one item in your checklist.

jonathanzh
  • 1,346
  • 15
  • 21