[英]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.我正在开发一个 Android 应用程序,我正在使用 Macbook Pro、Android Studio 2.1.2 Build #AI-143.2915827、JRE 1.8.0_91 和带有 Android 6 的三星 S6 设备来测试我的应用程序。 The problem is that android studio is disconnecting my device after sometime and it is not even showing me in list.问题是 android studio 在一段时间后断开了我的设备,它甚至没有在列表中显示我。 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?谁能告诉我是否有解决此问题的方法,即 android studio 经常断开测试设备的连接?
Thanks.谢谢。
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: hans...@meetme.com, vs...@google.com
###########################################################
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.只需将上面的代码保存为.sh文件并使用终端运行它。 Now you will not face disconnection issue.现在您将不会面临断线问题。
对我来说,它正在更改修复它的 USB 端口。
I fixed it by changing from a USB 3.0 to a USB 2.0.我通过从 USB 3.0 更改为 USB 2.0 来修复它。 Similar answer here: Android device keeps disconnecting from adb类似的答案在这里: Android 设备不断断开与 adb 的连接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.