2

每次我在 AVD 中启动我的应用程序时,我都会弹出这个快乐的小错误:

Error running app:
Unable to open debugger port (localhost:8611): java.net.ConnectionException "Connection refused"

(会张贴截图,但我的声誉不允许)

它并没有破坏任何东西,在几次重新启动后它又回到了正轨,但它开始让我烦恼。有谁知道如何解决这一问题?我正在寻找一个永久性的解决方案,而不是每次发生这种情况时都需要我一遍又一遍地做十件事的解决方案

Debian 8.2 上的 Android Studio 版本 1.5.1,使用 Oracle 的 java 1.8.0_66。

另外,澄清一下,这不是我的代码的问题。我可以启动一个完全空的项目,但仍然会弹出这个错误来打个招呼。


在独立终端中运行adb start-server会产生以下结果:

cytodev@GE72-2QE:~$ adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

这使用的端口与 Android Studio 使用的调试器端口不同,但我猜这是正常的。

4

1 回答 1

2

There is an issue around IP v6 and how localhost is handled. To fix the problem you will need to modify host file - see instruction. (I don't deal much with Linux but I think it's similar configuration for both Windows and Linux)

Windows (Must open with administrator permission)

  1. locate host file - C:\Windows\System32\Drivers\etc\hosts
  2. uncomment (remove #) the following line: # ::1 localhost

Linux (Must open with root)

  1. locate host file - /etc/hosts
  2. either add or uncomment ::1 localhost to the configuration file
于 2016-01-27T20:09:45.860 回答