如何将 Android 模拟器连接回 ADB?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2236120/
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 05:05:26  来源:igfitidea点击:

How to attach back the Android emulator to ADB?

androideclipseandroid-emulatoremulationadb

提问by Pentium10

After I start the emulator by hitting Debug in Eclipse, after certain time it disconnects from the ADB, but the emulator stays open. It is responsive, I can navigate and start apps.

在我通过在 Eclipse 中点击 Debug 启动模拟器后,一段时间后它与 ADB 断开连接,但模拟器保持打开状态。它是响应式的,我可以导航和启动应用程序。

How can I attach back the emulator to ADB, to be able to debug from Eclipse?

如何将模拟器连接回 ADB,以便能够从 Eclipse 进行调试?

(the current workaround is the terminate the emulator, close Eclipse and restart both of them, which takes 10 minutes as you know the emulator needs time to start up)

(当前的解决方法是终止模拟器,关闭 Eclipse 并重新启动它们,这需要 10 分钟,因为您知道模拟器需要时间启动)

EDIT 1
Check out this image:

编辑 1
查看此图像:

enter image description here

在此处输入图片说明

EDIT 2

编辑 2

After I kill and restart server. One emulator process shows up in Devices tab in Eclipse. But that cannot be expanded, and I don't see sub-processes.
I can't hit debug already, as it says: Debug already running. (How to I stop the debug?)

在我杀死并重新启动服务器之后。一个模拟器进程显示在 Eclipse 的 Devices 选项卡中。但这不能扩展,我看不到子流程。
我已经不能点击调试了,因为它说:调试已经在运行。(如何停止调试?)

If I managed to start the debugging of another project, It hangs out in the emulator telling me: Waiting for the debugger to attach. Nothing happens.

如果我设法开始调试另一个项目,它会在模拟器中显示出来,告诉我:等待调试器附加。没发生什么事。

回答by Dave Webb

As you said, the problem is not Eclipse losing contact with the Emulator, but ADB - the Android Debug Bridge- losing contact with it. As Eclipse uses ADB to communicate with the emulator when ADB is broken Eclipse can do nothing.

正如您所说,问题不是 Eclipse 与模拟器失去联系,而是 ADB - Android 调试桥- 与它失去联系。由于 Eclipse 在 ADB 损坏时使用 ADB 与模拟器进行通信,因此 Eclipse 无能为力。

To fix this stop the ADB serverby running the following command:

要解决此问题,请运行以下命令停止 ADB 服务器

adb kill-server

Eclipse will then usually try to restart ADB, or you can restart it yourself by running an ADB command, such as:

然后 Eclipse 通常会尝试重新启动 ADB,或者您可以通过运行 ADB 命令自行重新启动它,例如:

adb devices

If you do, you'll see output like this:

如果你这样做,你会看到这样的输出:

* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
emulator-5554   device

You can also do this via the mouse, using the Reset adboption in the Devicesview in Eclipse.

您也可以通过鼠标执行此操作,使用Eclipse 中设备视图中的重置 adb选项。

alt text

替代文字

It's also worth noting the Consoleview has two modes, DDMSand Android. You're usually in Consolemode but it's DDMSmode which will show ADB status messages. Select modes by clicking the button with the Monitor icon, or using the arrow next to it:

还值得注意的是,控制台视图有两种模式,DDMSAndroid. 您通常处于Consolemode 但它的DDMSmode 将显示 ADB 状态消息。通过单击带有监视器图标的按钮或使用旁边的箭头来选择模式:

alt text

替代文字

If all else fails, try killing the adb processes from the OS. On Windows XP I use:

如果所有其他方法都失败了,请尝试从操作系统中终止 adb 进程。在 Windows XP 上,我使用:

TASKKILL /F /IM adb.exe

回答by Munim Dibosh

There is an easier way. From eclipse you can reset the adb from DDMSpanel. Here's a short video on doing that "Reset ADB on DDMS"

有一个更简单的方法。在 Eclipse 中,您可以从DDMS面板重置 adb 。这是一个关于“在 DDMS 上重置 ADB”的简短视频

Here's a quick screenshot of where you can get the option.enter image description here

这是您可以获得该选项的快速屏幕截图。在此处输入图片说明

回答by Munim Dibosh

Try with adb kill-server and adb start-server. Even then the same problem occurs kill your running process from ddms prespective. Refer this link(http://www.jiahaoliuliu.com/2011/02/stopping-android-applications-already.html). This solved my issue. Hope for you also.

尝试使用 adb kill-server 和 adb start-server。即使发生同样的问题,也会从 ddms 中杀死您正在运行的进程。请参阅此链接(http://www.jiahaoliuliu.com/2011/02/stopping-android-applications-already.html)。这解决了我的问题。也希望你。

回答by rflexor

Sometimes a kill-server won't help at my machine (WinXP). For example I can't see the emulator in the DDMS-View any more or I do see it but no processes running on it.

有时kill-server 对我的机器(WinXP)没有帮助。例如,我再也看不到 DDMS-View 中的模拟器,或者我确实看到了它但没有进程在其上运行。

In these cases I close the emulator and eclipse and manually kill the adb.exe-process from the process list.

在这些情况下,我关闭模拟器和 eclipse 并从进程列表中手动终止 adb.exe 进程。

When I then restart eclipse and the emulator, everything's fine again.

当我重新启动 eclipse 和模拟器时,一切又好了。

Now I just need a keyboard-shortcut for that :-)

现在我只需要一个键盘快捷键:-)

回答by user1409438

on a mac, i just had to kill adb from activity manager and manually re-open the program again. had eclipse open all through and it worked just fine.

在 Mac 上,我只需要从活动管理器中杀死 adb 并再次手动重新打开程序。eclipse 一直打开,它工作得很好。

回答by Zorayr

I am testing an application on an Android 4.0 (API level 14) emulator and once I run the app the emulator starts up and as soon as it loads, Eclipse DDMS disconnects from the emulator.

我正在 Android 4.0(API 级别 14)模拟器上测试应用程序,一旦我运行该应用程序,模拟器就会启动,并且一旦加载,Eclipse DDMS 就会与模拟器断开连接。

Here is the workaround that I am using: Open terminal, navigate to platform tools (C:\android-sdk\platform-tools\ or wherever you have your android-sdk installed), and run adb kill-server, and then run, adb start-server. DDMS should now list the emulator - from Java perspective, right click on the app -> Run As -> Android Application.

这是我正在使用的解决方法:打开终端,导航到平台工具(C:\android-sdk\platform-tools\ 或安装了 android-sdk 的任何地方),然后运行adb kill-server,然后运行,adb start-server。DDMS 现在应该列出模拟器 - 从 Java 的角度来看,右键单击应用程序 -> 运行方式 -> Android 应用程序。

Hope this helps.

希望这可以帮助。

回答by amit

My handy bash script

我方便的 bash 脚本

#!/bin/bash
./path/to/adb kill-server
./path/to/adb start-server
./path/to/adb devices