Android 无法打开选定的 VM 调试端口 (8700)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2800386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:26:45  来源:igfitidea点击:

Could not open Selected VM debug port (8700)

androideclipseremote-debugging

提问by John Gaby

I am trying to debug the android source using Eclipse by following the instructions found at:

我正在尝试按照以下说明使用 Eclipse 调试 android 源代码:

http://source.android.com/using-eclipse

http://source.android.com/using-eclipse

I have downloaded the source, and gotten it to build. I follow the directions in the link above and everything is fine until I run the ddms command. At this point, if Eclipse is running I get the error 'Could not open Selected VM debug port (8700)'. If I close Eclipse, then ddms runs with no problem, and I can the the processes on the emulator. However, if I now open Eclipse, I get the same error.

我已经下载了源代码,并开始构建它。我按照上面链接中的说明操作,一切都很好,直到我运行 ddms 命令。此时,如果 Eclipse 正在运行,我会收到错误消息“无法打开选定的 VM 调试端口 (8700)”。如果我关闭 Eclipse,则 ddms 运行没有问题,我可以在模拟器上运行进程。但是,如果我现在打开 Eclipse,则会出现相同的错误。

In any case, no matter what I do, if I attempt to remote debug, it always fails with 'Failed to connect to remote VM'.

在任何情况下,无论我做什么,如果我尝试远程调试,它总是失败并显示“无法连接到远程 VM”。

Any ideas?

有任何想法吗?

Thanks

谢谢

采纳答案by Tim Kryger

It looks like you have two problems:

看起来你有两个问题:

  1. You are trying to run DDMS twice.You do not need to run the free standing version of DDMS since there is version of it integrated in Eclipse as part of the Android plug-in. If you change to the DDMS perspective in Eclipse, I'm sure you will find that all the same features are available.

  2. You have not told DDMS which VM you want to debug at localhost:8700.Before you attempt to establish your remote debug connection, you must go to the DDMS perspective and click on the system_process (or whatever process you want to debug).

  1. 您正在尝试运行 DDMS 两次。您不需要运行 DDMS 的独立版本,因为它的一个版本作为 Android 插件的一部分集成在 Eclipse 中。如果您在 Eclipse 中切换到 DDMS 透视图,我相信您会发现所有相同的功能都可用。

  2. 您没有告诉 DDMS 您要在 localhost:8700 调试哪个 VM。在您尝试建立远程调试连接之前,您必须转到 DDMS 透视图并单击 system_process(或您想要调试的任何进程)。

回答by Colin

The Windows Host file that is messed up is at C:\WINDOWS\system32\drivers\etc, and it should contain this line:

搞砸的 Windows 主机文件在C:\WINDOWS\system32\drivers\etc,它应该包含这一行:

127.0.0.1 localhost

If that doesn't work, then try making the following changes in Eclipse.

如果这不起作用,请尝试在 Eclipse 中进行以下更改。

Under Window -> Preferences -> Android -> DDMS:

在窗口 -> 首选项 -> Android -> DDMS 下:

  • Set Base local debugger port to "8601"
  • Check the box that says "Use ADBHOST" and the value should be 127.0.0.1
  • 将 Base 本地调试器端口设置为“8601”
  • 选中“使用 ADBHOST”框,该值应为 127.0.0.1

回答by Pallav

I solved it by ending the process "adb.exe" through Task Manager and then reloading the SDK through Windows->Preference..I am running Eclipse Indigo on Win 7 64-bit.

我通过任务管理器结束进程“adb.exe”,然后通过 Windows->Preference 重新加载 SDK 解决了这个问题。我在 Win 7 64 位上运行 Eclipse Indigo。

回答by aenw

I was having that problem too (Windows 7), even though my /Windows/system32/drivers/etc/hosts file already had 127.0.0.1 localhostin it.

我也有这个问题(Windows 7),即使我的 /Windows/system32/drivers/etc/hosts 文件已经127.0.0.1 localhost在里面了。

I tried changing the ADBHOST info & port in the eclipse Preferences, but that didn't do anything.

我尝试在 eclipse Preferences 中更改 ADBHOST 信息和端口,但这没有做任何事情。

netstat -bshows '127.0.0.1' as the source address for adb and the emulator, but always lists my machine host name as the 'foreign address.' On a hunch, I tried debugging with my machine not connectedto any network (no WiFi, nothing plugged in)... and it worked! (DDMS was able to connect to the VM on the emulated device and I was able to debug just fine.)

netstat -b显示“127.0.0.1”作为 adb 和模拟器的源地址,但总是将我的机器主机名列为“外国地址”。凭直觉,我尝试在我的机器没有连接到任何网络(没有 WiFi,没有插入任何东西)的情况下进行调试……并且成功了!(DDMS 能够连接到模拟设备上的 VM,我能够很好地调试。)

I think that messages sent by DDMS &/or adb are not staying on my local machine (they're getting sent to my local router). (It's just a guess; I don't know how to conclusively test that.) IOW, loopback wasn't working as it should.

我认为 DDMS 和/或 adb 发送的消息不会留在我的本地机器上(它们被发送到我的本地路由器)。(这只是一个猜测;我不知道如何最终测试它。) IOW,环回没有按预期工作。

Since I already had 127.0.0.1 in my localhosts, I added the local subnet address of my machine into my hosts file, guessing that DDMS/adb might be using that address (vs. 127.0.0.1). That seemed to solve the problem for me.

由于我的本地主机中已经有 127.0.0.1,我将我机器的本地子网地址添加到我的主机文件中,猜测 DDMS/adb 可能正在使用该地址(与 127.0.0.1 相比)。这似乎解决了我的问题。

So now my hosts file has these lines:

所以现在我的主机文件有这些行:

127.0.0.1       localhost
::1             localhost
192.168.1.102       localhost

(The local IPv4 address for my machine is 192.168.1.102. You can check yours with the ipconfigcommand.)

(我机器的本地 IPv4 地址是192.168.1.102。你可以用ipconfig命令检查你的。)

(I came across some webpages that how to set up a virtual network adapater for Windows that handles loopback, e.g. Setting up a Microsoft Loopback Adapater (from Oracle Distilled), but haven't had time to take that in and see if that's a viable solution to all of this, too.)

(我遇到了一些关于如何为处理环回的 Windows 设置虚拟网络适配器的网页,例如设置 Microsoft 环回适配器(来自 Oracle Distilled),但还没有时间考虑它是否可行也可以解决所有这些问题。)

回答by sid_09

I solved it by opening the windows Task manager and closing the process "adb.exe". Then close eclipse and reopen it. It will start properly without any error.

我通过打开 Windows 任务管理器并关闭进程“adb.exe”来解决它。然后关闭eclipse并重新打开它。它将正常启动而不会出现任何错误。

回答by Taehoon Kee

This is for reference. But I guess this might match your case.

这是供参考。但我想这可能符合你的情况。

Port 8700 is very special port for ddms; there's no way to change the port. Port 8700 is used for aggregating the packet from every Dalvik VM.

8700端口是ddms非常特殊的端口;没有办法改变端口。端口 8700 用于聚合来自每个 Dalvik VM 的数据包。

There will be two cases;

会有两种情况;

case 1) If you set "Base local debugger port"(in Eclipse ddms preference dialog) to 8700, then you'll see error - "Can't bind to local 8700 for debugger", everytime ddms initiated. But no problem, because if ddms couldn't bind 8700 to the first VM, then will be connected to 8701, and then 8702 and so on.

情况 1)如果您将“基本本地调试器端口”(在 Eclipse ddms 首选项对话框中)设置为 8700,那么每次启动 ddms 时,您都会看到错误 -“无法绑定到本地 8700 进行调试器”。但是没问题,因为如果ddms无法将8700绑定到第一个VM,那么将连接到8701,然后是8702,依此类推。

case 2) Even if you set "Base local debugger port"(in Eclipse ddms preference dialog) to 8600, you may see error - "Can't bind to local 8700 for debugger", in some cases. Because, if your device have more than or equal to 100 dalvik VMs, port assigning to each VM starting from port 8600 may reach to 8700 port. But, no problem occurs same as in case 1).

情况 2) 即使您将“基本本地调试器端口”(在 Eclipse ddms 首选项对话框中)设置为 8600,在某些情况下,您也可能会看到错误 -“无法绑定到本地 8700 进行调试器”。因为,如果您的设备有超过或等于100个dalvik VM,则从8600端口开始分配给每个VM的端口可能会达到8700端口。但是,不会出现与情况 1) 相同的问题。

So, if you really don't want to see the error, you have to set the "Base local debugger port"in Eclipse ddms preference dialog to 8701 or above.

因此,如果您真的不想看到错误,则必须将 Eclipse ddms 首选项对话框中的“Base local debugger port”设置为 8701 或更高版本。

Stand-alone ddms or android monitor uses different setting file from Eclipse, so it may not make this kind of problems.

独立的 ddms 或 android 监视器使用与 Eclipse 不同的设置文件,因此可能不会出现此类问题。

~

~

回答by Omar Faroque Anik

This type problem occurs when you are using another VM with the same port number. As an example you are using Android SDk full bundle which you have downloaded from the android developer website. Now you want to use Eclipse and plugged in ADT, SDK. There is a high probability to happen this type of error. It happened to me. To overcome this difficulties you can do :
Window-Preferences-Android- Choose DDMS- Change base local debugger port(use 8601 instead of 8600).
It can work. Thanks

当您使用另一个具有相同端口号的 VM 时,会出现这种类型的问题。例如,您使用的是从 android 开发者网站下载的 Android SDk 完整包。现在要使用Eclipse并插入ADT,SDK。发生此类错误的可能性很高。它发生在我身上。要克服这个困难,您可以执行以下操作:
Window-Preferences-Android-选择 DDMS-更改基本本地调试器端口(使用 8601 而不是 8600)。
它可以工作。谢谢

回答by Hari_krish4

I done it by restarting my computer

我通过重新启动计算机来完成

回答by Ege Akpinar

Had the same problem, different port numbers in the console output (where I launch ddms) caught my attention

有同样的问题,控制台输出(我启动 ddms 的地方)中的不同端口号引起了我的注意

Then from the documentation, I learned that 8600 is the default base port number. Every new process uses the next available port (8601,8602,...). In addition, 8700 is the default active port number (indicating the currently selected process in the dbms)

然后从文档中,我了解到 8600 是默认的基本端口号。每个新进程都使用下一个可用端口(8601,8602,...)。另外,8700是默认的活动端口号(表示dbms中当前选中的进程)

Here are the steps to debugging Android source+applications

下面是调试Android源码+应用的步骤

  1. Run emulator
  2. Run ddms
  3. Open Eclipse (It may complain about being unable to connect to 8600. This is because, when Eclipse starts up and if you have Android plugin, it boots up ddms. Since we already have a ddms connected to the device, trying to connect for a second time won't work)
  4. In the ddms, pick a thread you want to debug (when you highlight it, it will show you the ports that it is using as well as 8700 (e.g. "8649 / 8700"). This means you can use both ports to connect to this process
  5. From eclipse, using the remote debugging configuration, connect to any process you wish (easiest is to highlight the process from within ddms and then connect to 8700)
  1. 运行模拟器
  2. 运行 ddms
  3. 打开 Eclipse(可能会抱怨无法连接到 8600。这是因为,当 Eclipse 启动时,如果您有 Android 插件,它会启动 ddms。由于我们已经有一个 ddms 连接到设备,尝试连接一个第二次不行)
  4. 在 ddms 中,选择要调试的线程(突出显示它时,它会显示它正在使用的端口以及 8700(例如“8649 / 8700”)。这意味着您可以使用两个端口连接到这个流程
  5. 从 eclipse 中,使用远程调试配置,连接到您希望的任何进程(最简单的是从 ddms 中突出显示该进程,然后连接到 8700)

回答by plesatejvlk

Just for completeness: (on win 7/Vista) not only you have to make sure line

只是为了完整性:(在 win 7/Vista 上)不仅您必须确保线路

127.0.0.1 localhost

is present in

存在于

C:\WINDOWS\system32\drivers\etc

you also need to comment outall your other local virtual hostsresolving from 127.0.0.1. This is most probably the case if you're developing web stuff on the same machine and set it up earlier for different host names looping back to local.

您还需要注释掉从 127.0.0.1 解析的所有其他本地虚拟主机。如果您在同一台机器上开发 Web 内容并提前为循环回本地的不同主机名进行设置,则很可能是这种情况。