Android Studio 模拟器:无法添加库 vulkan-1.dll:失败

Android Studio Emulator: cannot add library vulkan-1.dll: failed

当我在 Windows 10 Pro 64 位中 运行 来自 Android Studio 的模拟器时,它会显示以下错误:

13-01-2021
10:42 AM    Emulator: handleCpuAcceleration: feature check for hvf

10:42 AM    Emulator: cannot add library vulkan-1.dll: failed

10:42 AM    Emulator: cannot add library vulkan-1.dll: failed

10:42 AM    Emulator: Process finished with exit code -1073741819 (0xC0000005)

并且模拟器打不开。我已经卸载了当前版本(4.1.1)并安装了Android Studio 4.0.1,但问题并没有解决。现在我使用的是最新版本的 Android Studio,即 4.1.1.

这是 flutter doctor 的输出:

如果你是 运行 xamarin.android 在 Visual Studio 中,我强烈建议卸载所有设备模拟器并重新启动 Visual Studio 然后 运行再次使用您的应用程序。

我昨天在安装最新版本的 Android Studio(稳定版 4.2.2)时遇到了同样的错误。每次我尝试启动模拟器时,我都会收到一条警告,说“AVD 的模拟器进程已被终止”,在查看 IDE 的日志后,我发现了这个:

2021-07-01 18:00:48,415 [  62545]   INFO - manager.EmulatorProcessHandler - Emulator: cannot add library vulkan-1.dll: failed
2021-07-01 18:00:48,415 [  62545]   INFO - manager.EmulatorProcessHandler - Emulator: cannot add library vulkan-1.dll: failed
2021-07-01 18:00:48,668 [  62798]   INFO - manager.EmulatorProcessHandler - Emulator: emulator: Android emulator version 30.7.5.0 (build_id 7491168) (CL:N/A)
2021-07-01 18:00:48,676 [  62806]   INFO - manager.EmulatorProcessHandler - Emulator: Process finished with exit code -1073741819 (0xC0000005)
2021-07-01 18:00:48,676 [  62806]   WARN - manager.EmulatorProcessHandler - Emulator terminated with exit code -1073741819

我尝试了所有我能找到的“解决方案”,但直到我下载 vulkan-1.dll 并将其放在 C:\Windows\System32

中才奏效

只需转到 Google 并搜索 vulkan-1.dll 文件,下载它并将其放在 C:\Windows\System32

是一个有效的解决方案。但是我不喜欢将来自 Internet 的任意 DLL 文件打包到 System32 文件夹中。

但是,根据 Armando 的解决方案,我找到了一种让我感觉更舒服的方法 - 但是,它仍然是一种解决方法:

  1. 例如可以在软件“draw.io”(64 位)中找到“vulkan-1.dll”。 DLL 在安装文件夹中可用。
  2. 将 DLL 复制到 {ANDROID_HOME}\emulator\lib64\
  3. 启动 Android Studio 并试用 AVD

四个步骤。

  1. 从 Internet 下载 vulkan DLL 文件或从任何合适的来源获取它。
  2. 提取 DLL 文件
  3. 放在c\Users\[你的用户名]\AppData\Local\Android\Sdk\emulator\lib64.
  4. 然后将文件重命名为'vulkan-1.dll'

然后 运行 你的模拟器,看看它会出现。

我遇到了同样的问题,emulator.exe 突然结束,控制台上出现相同的行。经过几个小时的实验,将模拟器版本从 Android Emulator 3.7.5 降级到 30.4.5.0 (build_id 7140946) 成功了。

我觉得这应该不是vulkan的错误-1.dll是进程突然结束的原因。我这么说是因为我在 30.4.5.0 (build_id 7140946) 上成功 运行 的日志也显示此 dll 丢失错误但继续并且模拟器成功显示。

emulator: Android emulator version 30.4.5.0 (build_id 7140946) (CL:N/A)
handleCpuAcceleration: feature check for hvf
emulator: WARNING: Your GPU drivers may have a bug. If you experience graphical issues, please consider switching to software rendering.
cannot add library vulkan-1.dll: failed
cannot add library vulkan-1.dll: failed
Failed to open /qemu.conf, err: 2
Windows Hypervisor Platform accelerator is operational
dsound: Could not initialize DirectSoundCapture
dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID
dsound: Attempt to initialize voice without DirectSoundCapture object
dsound: Attempt to initialize voice without DirectSoundCapture object
audio: Failed to create voice `goldfish_audio_in'
e:\Users\user\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: warning: opening audio input failed
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at 127.0.0.1:8554, security: Local
dsound: Attempt to initialize voice without DirectSoundCapture object
dsound: Attempt to initialize voice without DirectSoundCapture object
audio: Failed to create voice `adc'
Your emulator is out of date, please update by launching Android Studio:
 - Start Android Studio
 - Select menu "Tools > Android > SDK Manager"
 - Click "SDK Tools" tab
 - Check "Android Emulator" checkbox
 - Click "OK"

emulator: INFO: boot completed
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.

仅供参考。我正在 运行 在 Hyper-V 平台上的嵌套 VM 中安装模拟器,我的 GPU 版本是:

android_startOpenglesRenderer: gpu info

GPU #1
  Make: 1414
  Model: Microsoft Basic Render Driver
  Device ID: 008c

我不知道 Microsoft Visual Studio Code (VS Code) 本身是否需要 vulkan-1.dll 或我的任何以下 Visual Studio 代码扩展,

因为我发现您可能会在 Visual Studio 代码的以下文件夹路径中找到丢失的 vulkan-1.dll

C:\Users\{your_username}\AppData\Local\Programs\Microsoft VS Code\

因此,如果您安装了 Microsoft Visual Studio 代码,您 可以 在上述路径中找到 vulkan-1.dll。从这里,只需复制 vulkan-1.dll 文件,然后将其粘贴到文件夹中:

C:\Users\{your_username}\AppData\Local\Android\Sdk\emulator\lib64\

粘贴文件后,重新启动 Android Studio 并重新运行 emulator/AVD。

For Android 6

If you’re using Android 6 and above but less than Android 10 in Emulator then Re-Create the Emulator and Select Software – GLES 2.0 in the Emulated Performance while creating the AVD(or edit existing AVD).

For Android 10 or 11

If you’re using Android 10 or 11, then you can’t change the Emulated Performance (Graphics)

So for that, Edit the config.ini file of the AVD. Under Windows it’s located under C:/Users/<user_name>/.android/avd//config.ini (in my case is Nexus_5X_API_29.avd).

In a text editor change the line

hw.gpu.mode=auto

To

hw.gpu.mode=off

(This setting remains even if opened in the Android Virtual Device Manager of Android Studio. It’s just not editable there.

I also tried this, which I found in another AVD:

hw.gpu.enabled=yes
hw.gpu.mode=software

But this is then changed to “no” / “off” by the Android Virtual Device Manager. I didn’t look any further so far. hw.gpu.mode=off worked for me).

重新发布 (10k link only) with the actual content included, originally from https://professnow.com/blog/solved-emulator-cannot-add-library-vulkan-1-dll-failed/

自更新 v30.7.5 以来我遇到了这个问题。

我试过这个解决方案:

  1. 创建文件 ~/.android/advancedFeatures.ini(对于 Windows 用户路径应该是 C:\Users<用户名>.android\advancedFeatures.ini)内容如下:

    以下是禁用 Vulkan 应用程序与模拟器通信的方法。将以下行添加到 ~/.android/advancedFeatures.ini(如果该文件不存在则创建它):

    Vulkan = off
    
    GLDirectMem = on
    

对我来说,解决方案如 this Microsoft forum 中所述。

.android 目录下创建一个名为 advancedFeatures.ini 的文件并添加以下两个变量:

Vulkan = off
GLDirectMem = on

有关 Windows 和 Linux 的 Vulkan 支持的更多信息,请参见 here

使用以下 Android SDK 和工具:

SDk Tools Setup

SDK Platforms Setup

SDK Folder Structure

我有上面的 SDK 目录结构,我有一个 vulkan 驱动程序的文件夹,如上所示。我能够将文件:vk_swiftshader.dll 复制到父 lib64 目录,将其重命名为 vulkan-1.dll 以解决问题

错误:

  1. 转到帮助 -> 在资源管理器中显示日志。
  2. 打开 idea.log 文件。
  3. 转到文件底部。
  4. 找到:“Emulator: cannot add library vulkan-1.dll: failed

解决方案:

  1. this 下载 vulkan-1.dll
  2. 提取 dll 文件名并将其重命名为 vulkan-1.dll.
  3. 粘贴到C:\Windows\System32

降级模拟器 android API 版本,我在 API 30 时使用 我将它降级到 API28 并且模拟器开始工作

在 system32

中寻找 vulkan 运行时安装程序而不是复制 vulkan-1.dll

vulkan.lunarg.com/sdk/home

installer (1Mb)