Viral Joshi
Viral Joshi

Reputation: 317

Is there any fix for Android studio keep disconnecting test device in Macbook Pro?

I am developing an Android app and I am using Macbook Pro, Android Studio 2.1.2 Build #AI-143.2915827, JRE 1.8.0_91 and Samsung S6 device with Android 6 to test my apps. The problem is that android studio is disconnecting my device after sometime and it is not even showing me in list. I have tried almost every possible solution I have found on internet.

1) Kill adb server and start it again,
2) Unplug and plug back in device,
3) Unplug device, turn off developer mode, turn on developer mode in device, clear usb debugging authorizations, plug back in device,
4) Change SDK default location in macbook,
5) Restart test device and plug in,
6) Download updated SDK and replace old platform-tools folder 
7) Tried changing cables
8) Cleaned and reformatted Macbook with new OS

(I found sixth solution here)

and almost every single suggestion/answer I found online. But still it is not working. So does anyone have any idea how can I fix this problem? I am not able to test my application on this device. I do not have any other device and I don't have any other option to test my app. Can anyone tell me if there is a fix for this issue where android studio disconnects test device frequently?

Thanks.

Upvotes: 10

Views: 8208

Answers (4)

paulorrfilho
paulorrfilho

Reputation: 59

I fixed it by changing from a USB 3.0 to a USB 2.0. Similar answer here: Android device keeps disconnecting from adb

Upvotes: 2

Ahmed U3
Ahmed U3

Reputation: 698

For me it was changing the usb port that fixed it.

Upvotes: 5

Giorgio Fellipe
Giorgio Fellipe

Reputation: 304

Update your Android SDK Platform-tools to version 24.0.4 or later

Check out the issue report here

Upvotes: 1

Rohan Kandwal
Rohan Kandwal

Reputation: 9336

I had been facing the same issue as well. On some digging, found out that the issue has already been reported and a possible fix might come out soon. Use following script as a workaround fix for disconnection issue -

#!/bin/bash

cat << EOF
###########################################################
# Workaround adb disconnecting issue on macOS Sierra
#
# More info:
# https://code.google.com/p/android/issues/detail?id=219085
# credits to: [email protected], [email protected]
###########################################################

EOF

function each_device() {
  DEVICES=( $(adb devices | tail -n +2 | cut -sf 1) )

  for DEVICE in ${DEVICES[@]}
  do
    adb -s ${DEVICE} $@
  done
}

function monitor_adb () {
  adb start-server
  echo "[$(date)] adb started"

  while [ "$(each_device shell echo 1)" ]; do sleep 5; done

  echo "[$(date)] adb is broken, restarting"

  adb kill-server
  adb start-server || adb start-server
  each_device reverse
}

while [ true ]; do time monitor_adb ; done

Just save the above code as .sh file and run it using terminal. Now you will not face disconnection issue.

Upvotes: 6

Related Questions