Android 模拟器无法工作:无法打开 /qemu.conf、未找到加速器等

Ale*_* A. 3 android qemu adb xamarin visual-studio-2019

Visual Studio Xamarin 再次出现问题。\n我目前拥有 Windows Pro 10.0.19043 和最新版本的 Visual Studio 2019 (16.10.4),其中包含以下组件:

\n
Microsoft Visual Studio Enterprise 2019\nVersion 16.10.4\nVisualStudio.16.Release/16.10.4+31515.178\nMicrosoft .NET Framework\nVersion 4.8.04084\nInstalled Version: Enterprise\nMicrosoft Visual C++ 2019\nASP.NET and Web Tools 2019   16.10.526.50910\nASP.NET and Web Tools 2019\nAzure App Service Tools v3.0.0   16.10.526.50910\nAzure App Service Tools v3.0.0\nC# Tools   3.10.0-4.21329.37+246ce641f04b67ef017655275d850bf902a8e40f\nC# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.\nCommon Azure Tools   1.10\nProvides common services for use by Azure Mobile Services and Microsoft Azure Tools.\nCookiecutter   16.10.21111.19\nProvides tools for finding, instantiating and customizing templates in cookiecutter format.\nExtensibility Message Bus   1.2.6 (master@34d6af2)\nProvides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.\nIntelliCode Extension   1.0\nIntelliCode Visual Studio Extension Detailed Info\nLinux Core Dump Debugging   1.0.9.31313\nEnables debugging of Linux core dumps.\nMicrosoft Continuous Delivery Tools for Visual Studio   0.4\nSimplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.\nMicrosoft JVM Debugger   1.0\nProvides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines\nMicrosoft Library Manager   2.1.113+g422d40002e.RR\nInstall client-side libraries easily to any web project\nMicrosoft MI-Based Debugger   1.0\nProvides support for connecting Visual Studio to MI compatible debuggers\nMicrosoft Visual C++ Wizards   1.0\nMicrosoft Visual C++ Wizards\nMicrosoft Visual Studio Tools for Containers   1.2\nDevelop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.\nMicrosoft Visual Studio VC Package   1.0\nMicrosoft Visual Studio VC Package\nMono Debugging for Visual Studio   16.10.15 (552afdf)\nSupport for debugging Mono processes with Visual Studio.\nNuGet Package Manager   5.10.0\nNuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/\nNVIDIA CUDA 11.0 Wizards   11.0\nWizards to create new NVIDIA CUDA projects and source files.\nProjectServicesPackage Extension   1.0\nProjectServicesPackage Visual Studio Extension Detailed Info\nPython   16.10.21111.19\nProvides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.\nPython - Profiling support   16.10.21111.19\nProfiling support for Python projects.\nRazor (ASP.NET Core)   16.1.0.2122504+13c05c96ea6bdbe550bd88b0bf6cdddf8cde1725\nProvides languages services for ASP.NET Core Razor.\nSQL Server Data Tools   16.0.62106.24090\nMicrosoft SQL Server Data Tools\nTest Adapter for Boost.Test   1.0\nEnables Visual Studio\'s testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.\nTest Adapter for Google Test   1.0\nEnables Visual Studio\'s testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.\nTypeScript Tools   16.0.30429.2002\nTypeScript Tools for Microsoft Visual Studio\nVisual Basic Tools   3.10.0-4.21329.37+246ce641f04b67ef017655275d850bf902a8e40f\nVisual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.\nVisual C++ for Cross Platform Mobile Development (Android)   16.0.31306.167\nVisual C++ for Cross Platform Mobile Development (Android)\nVisual C++ for Linux Development   1.0.9.31313\nVisual C++ for Linux Development\nVisual F# Tools   16.10.0-beta.21262.7+1b23bbeda88ea3cb9be9af777f4c99fa8663df81\nMicrosoft Visual F# Tools\nVisual Studio Code Debug Adapter Host Package   1.0\nInterop layer for hosting Visual Studio Code debug adapters in Visual Studio\nVisual Studio Container Tools Extensions   1.0\nView, manage, and diagnose containers within Visual Studio.\nVisual Studio Tools for CMake   1.0\nVisual Studio Tools for CMake\nVisual Studio Tools for Containers   1.0\nVisual Studio Tools for Containers\nVisualStudio.DeviceLog   1.0\nInformation about my package\nVisualStudio.Foo   1.0\nInformation about my package\nVisualStudio.Mac   1.0\nMac Extension for Visual Studio\nXamarin   16.10.000.234 (d16-10@ecaf29b)\nVisual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.\nXamarin Designer   16.10.0.115 (remotes/origin/c750fbf1bde3c720d077f51640fe197c6dac7cbe@c750fbf1b)\nVisual Studio extension to enable Xamarin Designer tools in Visual Studio.\nXamarin Templates   16.10.5 (355b57a)\nTemplates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.\nXamarin.Android SDK   11.3.0.4 (d16-10/ae14caf)\nXamarin.Android Reference Assemblies and MSBuild support.\n    Mono: b4a3858\n    Java.Interop: xamarin/java.interop/d16-10@f39db25\n    ProGuard: Guardsquare/proguard/v7.0.1@912d149\n    SQLite: xamarin/sqlite/3.35.4@85460d3\n    Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-10@c5732a0\nXamarin.iOS and Xamarin.Mac SDK   14.20.0.24 (c4b89cddb)\nXamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.\n
Run Code Online (Sandbox Code Playgroud)\n

安装的 Android 平台:\n平台 Android 11\n平台 Android 5

\n

已安装的 SDK 组件:\n镜头1\n镜头2\n镜头3

\n

然而,无论我如何尝试为不同版本的 API 创建虚拟设备,模拟器都无法工作。从 Visual Studio 启动时,模拟器加载窗口会永远冻结(或冻结很长一段时间)。当通过命令行启动时,模拟器 ( C:\\Program Files (x86)\\Android\\android-sdk\\tools\\emulator.exe) 会生成以下内容:

\n
PS C:\\Program Files (x86)\\Android\\android-sdk\\tools> ./emulator -avd nexus_one_lollipop_5_0_-_api_21 \nemulator: WARNING: encryption is off\nANGLE: D3D11: rx::Renderer11::generateConfigs\nemulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_new_posture_requested(int) ((null):0, (null))\n\n\nemulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_dismiss_posture_selection_dialog() ((null):0, (null))\n\n\nFailed to open /qemu.conf, err: 2\nIncompatible HAX module version 3,requires minimum version 4\nNo accelerator found.\nqemu-system-i386.exe: failed to initialize HAX: Invalid argument\n
Run Code Online (Sandbox Code Playgroud)\n

之后,qemu 进程将永远挂起。只能通过任务管理器中的kill来结束。

\n

该-no-snapshot-load选项对任何内容都没有影响。\n我以管理员身份运行所有内容,我也尝试以简单用户身份运行它 - 结果是相同的。

\n

如果我创建一个\xd0\xa1:\\qemu.conf文件,那么输出会发生变化:

\n
emulator: WARNING: encryption is off\nANGLE: D3D11: rx::Renderer11::generateConfigs\nemulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_new_posture_requested(int) ((null):0, (null))\n\n\nemulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_dismiss_posture_selection_dialog() ((null):0, (null))\n\n\nqemu-system-i386.exe:/qemu.conf:1: no group defined\nemulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_posture_valueChanged(int) ((null):0, (null))\n
Run Code Online (Sandbox Code Playgroud)\n

之后,模拟器不再挂起,只是输出后立即退出。

\n

我还想指出,另一个模拟器文件 ( C:\\Program Files (x86)\\Android\\android-sdk\\emulator\\emulator.exe) 产生的输出略有不同。我不明白为什么会这样以及它会产生什么影响。

\n
PS C:\\Program Files (x86)\\Android\\android-sdk\\emulator> ./emulator -avd nexus_one_lollipop_5_0_-_api_21\nemulator: WARNING: encryption is off\nC:\\Program Files (x86)\\Android\\android-sdk\\emulator\\qemu\\windows-x86_64\\qemu-system-i386.exe:/qemu.conf:1: no group defined\nPS C:\\Program Files (x86)\\Android\\android-sdk\\emulator>\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • 我尝试过其他类似问题的答案,但一切都保持不变。
  • \n
  • 我尝试重新安装 SDK 组件(先卸载,重新启动 PC,然后再次重新安装)。
  • \n
  • 我尝试恢复 VIsual Studio(我不知道它的作用,但在此过程中下载并安装了某些内容,并且设置被重置)。在导入旧设置之前,没有任何效果,就像之后一样。
  • \n
\n

现在我不知道该怎么办了。下一步是重新安装 Windows,但它太长且无聊,它需要大量设置 -我现在还没有准备好。

\n

很久没有使用Android开发了。似乎以前一切正常,但我不能说是多久以前。也许某些组件的定期更新破坏了模拟器......顺便说一句,该项目正在成功组装。但是,我无法在我的电脑上运行它。

\n

是否可以在不重新安装 Windows 的情况下解决该问题?如何?

\n

Ale*_* A. 5

我的问题是 Visual Studio没有执行任何操作对 HAXM是的,主要错误是他造成的。如果你的错误输出和我的类似,那么重要的问题就出在 HAXM 上。

事实证明,从 Android SDK 菜单安装和卸载 HAXM(如问题中的屏幕截图所示)并不意味着实际安装或卸载。

正如我在问题中所说,以前一切都对我有用,但我很长一段时间没有回到这个状态。所以,我安装了 HAXM,但是是旧版本。由于某种原因,Visual Studio 无法更新或卸载它。安装新版本时,旧版本不会被替换,并被视为优先级,因此安装新版本而不删除旧版本没有帮助。

如果您的旧 HAXM 安装程序(应卸载旧 HAXM)不起作用,请继续阅读。那么,我是如何修复错误的:

  1. 通过 Android SDK 菜单“删除”HAXM。
  2. 检查Device manager了HAXM(我没有删除这里的任何内容,因为我没有找到它)
  3. 从中删除了旧的 HAXM 文件夹C:\Windows\System32\DRVSTORE\intelhaxm_*
  4. 启动损坏的旧 HAXM 安装程序以删除 HAXM 注册表项。在手动干预之前,他不想工作,理由是缺少某种 .msi 文件。
  5. 重新启动电脑
  6. 我使用以下命令确保旧的 HAXM 已从系统中删除:C:\Program Files (x86)\Android\android-sdk\emulator> .\emulator-check.exe accel
  7. 通过 Android SDK 菜单“安装”HAXM。(在此步骤中,未安装任何内容 - 上一步中的命令仍报告没有 HAXM。)
  8. 从 Intel 官方存储库安装 HAXM:https://github.com/intel/haxm/releases
  9. 使用步骤 6 中的命令,我确保 HAXM 已正确安装(例如,显示我的 PC 上的输出):
PS C:\Program Files (x86)\Android\android-sdk\emulator> .\emulator-check.exe accel
accel:
0
HAXM version 7.7.0 (4) is installed and usable.
accel
Run Code Online (Sandbox Code Playgroud)

之后,模拟器应该可以工作。也许Android Device Manager会出现故障,显示设备模拟器已经在运行(但我没有找到qemu*和emulator处理)。也许,这可以更准确地解决,但我只是删除了现有设备并重新创建了它。