Ubuntu上的Android模拟器冻结

sczxawaw  于 2023-03-21  发布在  Android
关注(0)|答案(1)|浏览(128)

已在以下设备上安装Android Studio和模拟器版本31.* 或32.*(撰写本文时的最新版本):

OS: Ubuntu 22.04.2 LTS x86_64 
Kernel: 5.19.0-32-generic 
PC: HP EliteBook 840 G8 Notebook
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics] 
CPU: 11th Gen Intel i7-1165G7 (8) @ 4.700GHz.

我检查了CPU是否支持虚拟化:egrep -c '(vmx|svm)' /proc/cpuinfo返回16(16个结果,因此虚拟化应该没问题),已安装KVM内容:

kvm-ok                                                                                     
INFO: /dev/kvm exists
KVM acceleration can be used

然而,当我使用硬件图形(硬件GLES 2.0启用)运行AVD时,在Android设备上运行Google Chrome会冻结模拟器,并显示以下消息:error: kvm run failed Bad address,除了强制关闭模拟器之外,我没有其他选择。

uqcuzwp8

uqcuzwp81#

我在机器上启用Android模拟器的硬件加速时遇到了同样的问题:

Android Studio Electric Eel | 2022.1.1 Patch 2
Build #AI-221.6008.13.2211.9619390, built on February 17, 2023
Runtime version: 11.0.15+0-b2043.56-8887301 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.15.102-1-manjaro
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 16
Registry:
    external.system.auto.import.disabled=true
    debugger.new.tool.window.layout=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.experimental.ui=true

Non-Bundled Plugins:
    org.intellij.plugins.markdown (221.5787.39)
    IdeaVIM (1.10.3)

Current Desktop: XFCE

vulkan驱动程序似乎有问题。
尝试使用以下标志启动模拟器:-feature -Vulkan .
示例:

~/android/sdk/emulator$ ./emulator -avd Pixel_4a_API_33 -feature -Vulkan

如果您希望在运行android studio时永久使用此参数,请使用以下命令在~/.profile,~/.zprofile,~/.bash_profile中设置环境变量studio.emu.params
export studio.emu.params="-feature,-Vulkan"或将其添加到.desktop条目文件中:
~/.local/share/applications/jetbrains-studio.desktop

[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Icon=/opt/intellij/android-studio/bin/studio.svg
# added env variable for disabling qemu-vulkan
Exec=env studio.emu.params="-feature,-Vulkan" "/opt/intellij/android-studio/bin/studio.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-studio
StartupNotify=true

参见:

相关问题