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

4

10

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.

Alwyn answered 28/7, 2016 at 15:49 Comment(5)
Physical test devices are frequently plugged and unplugged. The cord or the connector could be damagedDunham
@cricket_007, cable is fine. I have tried some other cables too.Alwyn
Is the usb socket in the phone loose or damaged?Dunham
@cricket_007, nope. It is not. Everything is perfect. It is just android studio drops connection.Alwyn
Android Studio on Windows 10 has this issue 4 years later. I know the devices are still connected because Windows File Explorer is still allowing me to traverse the file structure on the phone.Feme
D
6

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.

Diplomat answered 29/9, 2016 at 17:31 Comment(6)
didn't work on AndroidStudio v:2.3 (adb v:1.0.36) on OSX, still have to remove the cable and attach again to get the device back!Lira
Are you sure code is always running in terminal? Btw I haven't face this issue in a while with recent Mac OS and Android Studio updates. @AbduliamRehmaniusDiplomat
Yes running the script from the terminal.app, the script does detect "daemon not running. starting it now on port...." but it keeps on restarting adb every 3 seconds and device is not re-detectedLira
@AbduliamRehmanius Have you tried different cable ? Because it worked for me when I had the same issue.Diplomat
I restarted a little while ago and it appears to be doing the job now, not sure why it wasn't working previously, thanks for the answer (y)Lira
It Works!!! Second day, script wasn't running, device went invisible in debugger window, started the script and device came back ... hopefully device's usb port will live longer now .... yayyy :pLira
C
5

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

Colettacolette answered 19/3, 2019 at 15:7 Comment(1)
Only for a day. The next day issue backs. It's macbook pro's new type c portsAdamsen
N
2

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

Nahshon answered 18/3, 2021 at 19:51 Comment(0)
H
1

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

Check out the issue report here

Hepatic answered 29/11, 2016 at 3:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.