在更新到Android Studio 2后,当我试图运行我的应用程序并选择一个模拟器时,我等待模拟器启动,它突然被杀死。我可以看到模拟器进程几分钟,但从来没有GUI。在Android studio中,我得到了错误

android studio Error while waiting for the device: The emulator process for AVD was killed

即使我在Android Studio之外运行模拟器也会发生这种情况。我试用了Android 6和基于Android 4.4的模拟器。 在Windows 7 x64 PC上运行。类似于另一个StackOverflow帖子被关闭。我尝试了各种ram、VM堆和分辨率设置。


当前回答

Android Studio v4.1及以上版本:

菜单-> Android Studio ->首选项->工具->模拟器

取消在工具窗口选项中的启动。

其他回答

我重新安装了Intel x86 Emulator Accelerator (HAXM安装程序)

在此之前,我尝试了很多方法,但只有一种有效:

配置->设置->外观和行为\系统设置\Android SDK -> SDK工具(选项卡)->取消选择“Intel x86 Emulator Accelerator (HAXM installer)”-> OK

现在,当你试图运行你的应用程序,或从AVD管理器启动设备时,它会给出“安装模拟器”错误->单击确定。这将自动下载新的“Intel x86 Emulator Accelerator (HAXM installer)”,我选择了512 RAM,它可以工作。

之后,我再次进行了所有这些处理,并选择了2 GB的RAM,它仍然工作。

这个错误非常普遍,这种症状可能是由于一百万个完全不同的问题中的任何一个造成的。 你要做的是找到更多关于正在发生的事情的信息,这样你就不会看起来像一只瞎鸡在啄食令人作呕的石头。 因此,让我们得到调试步骤:

first thing is to find the logs of Android studio. In doubt, stackoverflow already has a section to help you How to find the logs on android studio?. The text file should be named: "idea.log". You can open it with notepad, but only open it after android studio is closed (in windows 10). There will be a lot of events inside. Search by "manager.EmulatorProcessHandler" and the last date that you had the error. A good trick to facilitate your life, after having found the log file, is to close Android studio: delete the log file; reopen android studio and retry to open the emulator. The log file will be recreated with a lot less history and so it will be so much easier to search. In my case, i found: manager.EmulatorProcessHandler - Emulator: emulator: ERROR: Another emulator instance is running. Please close it or run all emulators with -read-only flag.. Given that, it is easy to solve. I just had to open a process manager and terminate the emu process that didn't correctly close for some unknown reason. Of course, in our case the log will be completely different. But now you have a clue of the hidden criminal.

简单解决方案2021

进入AVD管理器 找到您要使用的模拟器,然后单击向下箭头 选择“显示在磁盘上”选项 删除所有以.lock结尾的文件 再次运行模拟器,在此之后将初始化

如果你将模拟器升级到30+版本并运行mac < 10.15,我会得到同样的错误

如果从命令行运行它,就会看到真正的错误

~/Library/Android/sdk/模拟器-avd - <

emulator: Android emulator version 30.5.3.0 (build_id 7196367) (CL:N/A)
dyld: Library not loaded: /System/Library/Frameworks/IOUSBHost.framework/Versions/A/IOUSBHost

您可以通过以下步骤修复此问题,以升级到Big Sur或降级模拟器。

wget https://dl.google.com/android/repository/emulator-darwin-6885378.zip zip解压emulator-darwin-5395263。 mv ~/图书馆/Android/sdk/模拟器~/Library/Android/ Android/ Android/模拟器 mv模拟器~/图书馆/Android/sdk/模拟器 cp ~/Library/Android/sdk/ previoter /package.xml ~/Library/Android/sdk/ package.xml

检查是否成功:

cd ~ ~ /图书馆/ Android / sdk /模拟器/模拟器- version

28.0.25.0

~ /图书馆/ Android / sdk /模拟器/模拟器-list-avds

源https://groups.google.com/g/flutter-dev/c/uEthfwjZBAQ/m/HSFqTgYsAgAJ

2021年4月8日编辑:我更新了模拟器链接到评论中提到的新版本

如果您使用McAfee防病毒和Windows 10,这可能会帮助您:

根据snehatilak的建议,卸载并重新安装Android Emulator最初对我的情况有所帮助,但第二天模拟器又死机了。

我发现McAfee杀毒软件已经隔离了文件avd .conf,原来是在C:\Users[username].android\avd[avdImage]\

在恢复AVD.conf并从扫描中排除它之后,它似乎又好了。

这一切都始于2021年2月2日,我猜是在McAfee更新之后。

以下是步骤:

首先转到“设置”下的“隔离项目”并恢复AVD.conf文件

然后转到“设置”下的“实时扫描”,在你创建的每个模拟器中排除AVD.conf。(位于C:\Users[username].android\avd[avdImage])