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

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

问题描述

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

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

我目前使用的是运行 Android 4.4.4 的三星 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
构建 #AI-145.3360264,于 2016 年 10 月 18 日构建
JRE:1.8.0_112-release-b05 x86_64
JVM:JetBrains s.r.o 的 OpenJDK 64 位服务器虚拟机

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)

我可以成功连接并运行应用程序,我只是在执行 Run > Debug App > 选择连接的手机 > OK 时无法连接调试器.

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

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$$ # 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 进程

Searching for and killing adb processes

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

  • 重启安卓工作室

  • 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 进程 - 这没有帮助

    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 中附加调试器 - localhost:8600 java.net.ConnectException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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