无法在Android Studio中附加调试器-本地主机:8600 java.net.ConnectException [英] Unable to attach debugger in Android Studio - localhost:8600 java.net.ConnectException

查看:200
本文介绍了无法在Android Studio中附加调试器-本地主机:8600 java.net.ConnectException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在手机上运行调试时,我无法在Android Studio中附加调试器.

I cannot attach the debugger in Android Studio while running debug on a phone.

我目前正在使用运行Android 4.4.4的Samsung S4(但已经在各种Android版本上尝试了S5,S6,S7和Moto E手机).当我尝试运行它时出现以下错误之一,它超时:

I’m currently using a Samsung S4, running Android 4.4.4 (but have tried an S5, S6, S7, and Moto E phone on various Android versions). It times out when I try to run it with either of the following errors:

I/System.out:正在发送等待块
W/ActivityThread:应用程序正在端口8100上等待调试器...

I/System.out: Sending WAIT chunk
W/ActivityThread: Application is waiting for the debugger on port 8100...

无法打开调试器端口localhost:8600 java.net.ConnectException连接被拒绝"

failed to open debugger port localhost:8600 java.net.ConnectException "connection refused"

然后应用显示:

等待调试器
应用程序(进程)正在等待调试器附加.
强制关闭

Waiting For Debugger
Application (process ) is waiting for the debugger to attach.
Force Close

Android Studio版本:

Android Studio version:

Android Studio 2.2.2
Build#AI-145.3360264,建于2016年10月18日
JRE:1.8.0_112-release-b05 x86_64
JVM:JetBrains s.r.o

Android Studio 2.2.2
Build #AI-145.3360264, built on October 18, 2016
JRE: 1.8.0_112-release-b05 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Mac版本:

10.11.6(15G1004)

10.11.6 (15G1004)

我可以成功连接并运行该应用程序,但在运行>调试应用程序>选择已连接的手机>确定后,我无法连接调试器.

I can successfully connect and run the application, I just can’t get the debugger to attach when I do Run > Debug App > select the connected phone > OK.

我已经能够在具有相同手机的其他计算机(Windows和Mac)上以调试方式运行该应用程序.

I have been able to run the app in debug on other computers (both Windows and Mac) with the same phones.

我从调试和在线搜索的时间中尝试了各种方法:

Various approaches I have tried from hours of debugging and online searching:

  1. 使缓存无效/重新启动Android Studio

  1. Invalidate Caches/Restart Android studio

检查端口8100、8600、8601等上是否有其他运行的东西,当我从bash运行以下命令时,什么也没回来:

Check for anything else running on ports 8100, 8600, 8601, etc., nothing comes back when I run the following from bash:

$ # while Android studio is trying to attach the debugger
$ lsof -i :8100
$ lsof -i :8600
COMMAND  PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME

工作室6282彼得125u IPv4 0x973c7e31bda641ab 0t0 TCP 192.168.1.16:64022->ip-166-62-27-181.ip.secureserver.net:asterix(SYN_SENT) $ lsof -i:8601 $ $#在Android Studio无法附加调试器之后 $ lsof -i:8100 $ lsof -i:8600 $ lsof -i:8601 $

studio 6282 peter 125u IPv4 0x973c7e31bda641ab 0t0 TCP 192.168.1.16:64022->ip-166-62-27-181.ip.secureserver.net:asterix (SYN_SENT) $ lsof -i :8601 $ $ # after Android studio fails to attach the debugger $ lsof -i :8100 $ lsof -i :8600 $ lsof -i :8601 $

运行工具> Android> Android设备监视器-它显示了我的设备,但在尝试调试应用程序时我无法运行Android设备监视器,它说:将关闭监视器以启用ADB一体化.继续?"我在这里没有发现任何有用的东西.

Run Tools > Android > Android Device Monitor - it shows my device, but I can’t run Android Device Monitor while I’m trying to debug the app, it says, "Monitor will be closed to enable ADB integration. Continue?" I haven’t found anything useful here.

搜索并杀死adb进程

ps aux | egrep '(adb|java)'
... then doing `kill <pid>` or `kill -9 <pid>` if necessary for the found ones

  • 重新启动Android Studio

  • Restart Android studio

    重新启动计算机

    从Oracle网站更新Java JDK,但是,我不确定为什么Android Studio仍然会说"JVM:JetBrains s.r.o的OpenJDK 64位服务器VM"

    Update Java JDK from the Oracle website—however, I’m not sure why Android Studio still says, "JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o"

    完全卸载并重新安装android studio-例如 https://stackoverflow.com/a/18458893/376489-奇怪的是,我认为这只适用于调试器的一次运行,然后再也不行了……

    Completely uninstall and reinstall android studio - e.g., https://stackoverflow.com/a/18458893/376489 - weirdly, I think this worked for one run of the debugger and then not again…

    尝试运行>将调试器附加到Android Process-这没有帮助

    Tried Run > Attach debugger to Android Process - this didn’t help

    尝试运行:

    ~/Library/Android/sdk/platform-tools/adb kill-server &&
     ~/Library/Android/sdk/platform-tools/adb start-server
    

  • 尝试取消选中运行">编辑配置">运行/调试配置">如果APK尚未更改,则跳过安装"

  • Tried unchecking Run > Edit Configurations > Run/Debug Configurations > Skip installation if APK has not changed

    检查系统偏好设置>安全性和隐私>防火墙-此功能已关闭

    Check System Preferences > Security & Privacy > Firewall - this is turned off

    更新1:尝试撤消手机上的权限以及重新启动手机

    Update 1: tried revoking permissions on the phone as well as restarting it

    更新1:静音所有断点Android Studio

    Update 1: muted all breakpoints Android Studio

    在我上面添加的详细信息中,可能还有什么问题或其他有意义的想法吗?

    Are there any other ideas for what might be going wrong or anything meaningful in the details I added above?

    推荐答案

    挺尴尬的,但是似乎前段时间我已经在/etc/hosts文件中输入了ip地址来测试localhost,但从未删除过它.我在另一篇文章中找到一条评论,说要检查以下内容是否在您的/etc/hosts中:

    Quite embarrassing, but it looks like some time ago I had entered an ip address into my /etc/hosts file to test something as localhost and never removed it. I found a comment on another post saying to check that the following is in your /etc/hosts:

    127.0.0.1       localhost
    255.255.255.255 broadcasthost
    ::1             localhost
    

    注释掉该虚假行后,调试器现在正在运行.鉴于我在该文件中还有十几个其他IP(因此我可以更容易地用一个友好的名称测试远程主机),我一定不会在底部注意到这一点.我认为一种更简单的方法来验证是否是问题所在是ping localhost并验证它可以解析为127.0.0.1的IP地址,例如

    Upon commenting out that spurious line, the debugger is now working. Given I have a dozen or so other IPs in that file (so I can more easily test remote hosts with a friendly name), I must have not noticed this one at the bottom. I think a more foolproof approach to verifying if this is the problem or not is to ping localhost and verify that it resolves to the ip address of 127.0.0.1, e.g.,

    $ ping localhost
    PING localhost (127.0.0.1): 56 data bytes
    

    这里的其他人也发表了很棒的评论和建议,谢谢!

    Great comments and suggestions from other folks here too, thanks!

    这篇关于无法在Android Studio中附加调试器-本地主机:8600 java.net.ConnectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆