Unable to attach debugger in Android Studio - localhost:8600 java.net.ConnectException
在手机上运行调试时,我无法在Android Studio中附加调试器。
我目前正在使用三星S4,运行Android 4.4.4(但在各种Android版本上尝试过S5,S6,S7和Moto E手机)。当我尝试使用以下任一错误运行它时会超时:
I/System.out: Sending WAIT chunk
W/ActivityThread: Application is waiting for the debugger on port 8100...
要么
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 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)
我可以成功连接并运行应用程序,当我执行Run> Debug App>选择已连接的手机>确定时,我无法让调试器连接。
我已经能够在其他计算机(Windows和Mac)上使用相同的手机在调试中运行该应用程序。
我从几个小时的调试和在线搜索中尝试过各种方法:
无效缓存/重启Android工作室
检查端口8100,8600,8601等上运行的其他任何东西,当我从bash运行以下命令时没有任何回复:
1 2 3 4 | $ # 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
$
运行工具> Android> Android设备监视器 - 它显示我的设备,但我在尝试调试应用程序时无法运行Android设备监视器,它说,"监视器将关闭以启用ADB集成。继续?"我在这里找不到任何有用的东西。
搜索并终止adb进程
1 2 | ps aux | egrep '(adb|java)' ... then doing `kill <pid>` or `kill -9 <pid>` if necessary for the found ones |
重启Android工作室
重启我的电脑
从Oracle网站更新Java JDK - 但是,我不确定为什么Android Studio仍然会说,"JVM:JetBrains s.r.o的OpenJDK 64位服务器VM"
完全卸载并重新安装android studio - 例如,https://stackoverflow.com/a/18458893/376489 - 奇怪的是,我认为这适用于调试器的一次运行,然后不再...
尝试运行>将调试器附加到Android进程 - 这没有帮助
试过跑步:
1 2 | ~/Library/Android/sdk/platform-tools/adb kill-server && ~/Library/Android/sdk/platform-tools/adb start-server |
尝试取消选中运行>编辑配置>运行/调试配置>如果APK未更改,请跳过安装
检查系统首选项>安全和隐私>防火墙 - 此功能已关闭
更新1:尝试撤消手机上的权限以及重新启动它
更新1:默认所有断点Android Studio
对于我上面添加的细节中可能出现的问题或任何有意义的内容,还有其他想法吗?
相当尴尬,但它看起来像前一段时间我已经在我的/ etc / hosts文件中输入了一个ip地址来测试
1 2 3 | 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost |
在评论出该虚假线路时,调试器现在正在工作。鉴于我在该文件中有十几个其他IP(因此我可以更容易地测试具有友好名称的远程主机),我一定不会在底部注意到这个。我认为验证这是否是问题的一种更加万无一失的方法是ping localhost并验证它是否解析为127.0.0.1的ip地址,例如,
1 2 | $ ping localhost PING localhost (127.0.0.1): 56 data bytes |
非常感谢来自其他人的好评和建议,谢谢!
我刚刚经历过同样的问题。看起来好像Android Studio 2.2在非附加调试器方面存在一些问题,例如你可以在这里和这里看到。
在我的情况下,以下帮助:
- 通过转到"运行" - >"编辑配置..."并删除其中的配置文件,删除应用的启动配置文件。删除配置文件后,请不要忘记按"确定"按钮。 :)
- 再次转到Run - > Edit Configurations ...,点击+按钮,选择Android App启动配置文件并选择启动模块,从头开始创建新的启动配置文件。配置文件的其他默认值就好了。
希望这对你也有帮助。
我正在使用真实的设备。只需删除设备上的应用程序,然后从Android Studio运行即可解决此问题。
似乎Android Studio在覆盖手机上已有的文件时遇到了麻烦。
Support for a true debug build. Developers no longer need to add the android:debuggable attribute to the tag in the manifest — the build tools add the attribute automatically. In Eclipse/ADT, all incremental builds are assumed to be debug builds, so the tools insert android:debuggable="true". When exporting a signed release build, the tools do not add the attribute. In Ant, a ant debug command automatically inserts the android:debuggable="true" attribute, while ant release does not. If android:debuggable="true" is manually set, then ant release will actually do a debug build, rather than a release build.
BLOCKQUOTE>
在我的情况下,我用5小时挣扎这个问题,发现了
minifyEnabled true 是罪魁祸首所以改变
minifyEnabled false 为我工作我的app build.gradle文件看起来像
1
2
3
4
5
6
7
8
9 buildTypes {
debug {
signingConfig signingConfigs.debug
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
我也有同样的错误,这件事对我有用
1
2
3 1. Open Android Studio -> Terminal
2. Change directory to $Android SDK Path$\platform-tools
3. Write command adb get-state and hit enter.然后你会得到这个输出
1
2 * daemon not running. starting it now on port 5037 *
* daemon started successfully *
1.try清洁项目Build-> clean project
2.do file-> Invalidate / cache restart
如果上面没有帮助你..3.更改用于连接手机的数据线。
如果上面没有任何帮助,安装Android wifi ADB插件,并尝试通过wifi进行调试。
我有与Android Studio 3.3相反的问题,试图调试一个连接Wi-Fi的手机。
在Android Studio中选择设备后,我收到以下消息:
Error running 'app': Unable to open debugger port (localhost:8600):
java.net.ConnectException"Connection refused: connect"我的网络上也启用了IPV-6。
问题是默认情况下"localhost"在我的机器上解析为:: 1,但ADB明确地明确绑定到127.0.0.1。我碰巧知道这一点,因为我花了一天时间试图让ADB连接到在远程机器上运行的模拟器(不幸的是,不管Android 4.4。
要解决此问题,请将以下行添加到 windows system32 drivers etc hosts:
127.0.0.1 localhost
只是不使用我的谷歌像素第一代和使用我的新诺基亚7 +修复此问题:)。
尝试在终端上使用以下命令 -
adb kill-server
adb start-server
它运作良好。
起初我尝试了以上所有方法,没有帮助。
我有两台设备相同的电脑。
但是,其中一个工作在其他错误。
它给了我一个想法,它可能是"硬件"问题。
我用USB3.0将USB切换到其他插槽,并使用短电缆和
哇它开始工作了。
我建议在USB2.0(轮询)中有一些延迟,因此进程开始不同步。