我是一位使用 Android Studio 的初学者,在尝试启动模拟器时遇到问题。尽管尝试了多次故障排除(包括跨不同版本重新安装 Android Studio、重新启动 PC、执行冷启动、擦除模拟器数据以及为具有不同 API 级别的多个设备创建模拟器),但无论模拟器配置如何,都会出现相同的错误。
尝试启动模拟器时出错: 模拟器启动时出错
C:\Users{user_name}\AppData\Local\Google\AndroidStudio{version}\log\idea.txt 中的错误日志显示以下条目:
2024-11-13 10:54:06,796 [ 14130] INFO - Emulator: Pixel 3a - Process finished with exit code -1073741819 (0xC0000005)
2024-11-13 10:54:06,796 [ 14130] WARN - Emulator: Pixel 3a - Emulator terminated with exit code -1073741819
模拟器进程似乎意外终止,退出代码为 -1073741819 (0xC0000005)。我的设备有足够的存储空间。
有人可以提供解决此错误的指导吗?
尝试过:
预期:
实际结果:
更新:运行模拟器作为 ```PS C:\Users\{user_name}\AppData\Local\Android\Sdk mulator> ./emulator -gpu off -avd Pixel_3a``` 运行模拟器但不会打开直接通过android studio,这对我来说是主要问题。另外,如果需要附加信息,图形加速默认设置为automatic并且呈灰色(我无法更改它)。 如果其他选项设置为像主机一样的gpu,那么它会崩溃,如下:
PS C:\Users\{user_name}\Desktop> C:\Users\{user_name}\AppData\Local\Android\Sdk\emulator/emulator -gpu host -avd Pixel_3a
INFO | Android emulator version 35.4.1.0 (build_id 12623485) (CL:N/A)
INFO | Graphics backend: gfxstream
INFO | Found systemPath C:\Users\{user_name}\AppData\Local\Android\Sdk\system-images\android-30\google_apis_playstore\x86\
INFO | Found systemPath C:\Users\{user_name}\AppData\Local\Android\Sdk\system-images\android-30\google_apis_playstore\x86\
WARNING | Please update the emulator to one that supports the feature(s): Vulkan
INFO | IPv4 server found: ....
INFO | Ignore IPv6 address: ....
INFO | Ignore IPv6 address: ....
INFO | Checking system compatibility:
INFO | Checking: hasSufficientDiskSpace
INFO | Ok: Disk space requirements to run avd: `Pixel_3a` are met
INFO | Checking: hasSufficientHwGpu
INFO | Ok: Hardware GPU requirements to run avd: `Pixel_3a` are passed
INFO | Checking: hasSufficientSystem
INFO | Ok: System requirements to run avd: `Pixel_3a` are met
WARNING | FeatureControl is requesting a non existing feature.
INFO | Warning:
INFO | Warning:
INFO | Storing crashdata in: C:\Users\{user_name}\AppData\Local\Temp\\AndroidEmulator\emu-crash-35.4.1.db, detection is enabled for process: 8128
INFO | Crash reports will be automatically uploaded to: https://clients2.google.com/cr/report
library_mode host gpu mode host
PS C:\Users\{user_name}\Desktop>
我在两个路径 C:\Windows\System32 和 *{ANDROID_HOME} mulator\lib64* 中都有 vulkan-1.dll 文件,如此处所述。
按顺序尝试这些解决方案,因为它们从简单到更复杂的修复:
# Run emulator with GPU off
cd %ANDROID_HOME%/emulator
./emulator -gpu off -avd YOUR_AVD_NAME
或者修改AVD配置:
Control Panel → 3D Settings → Program Settings
Add Android Emulator and set:
- OpenGL rendering: Force software
- Power management: Prefer maximum performance
# Add these to System Variables
ANDROID_HOME=C:\Users\[username]\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Microsoft\jdk-17.0.8.7-hotspot\
Path=%Path%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\emulator
# Windows PowerShell commands
Remove-Item -Recurse -Force "${env:USERPROFILE}\.android\avd\*"
Remove-Item -Recurse -Force "${env:LOCALAPPDATA}\Android\Sdk\system-images\*"
# Reinstall system images
sdkmanager --install "system-images;android-30;google_apis_playstore;x86"
# Create AVD via command line with optimal settings
avdmanager create avd -n "Pixel_3a_API_30" \
-k "system-images;android-30;google_apis_playstore;x86" \
-d "pixel_3a" \
--force
# Edit config.ini
notepad %USERPROFILE%\.android\avd\Pixel_3a_API_30.avd\config.ini
将这些行添加到 config.ini:
hw.gpu.enabled=yes
hw.gpu.mode=off
disk.dataPartition.size=6442450944
编辑
studio64.exe.vmoptions
:
# Location: %APPDATA%\Google\AndroidStudio[version]\studio64.exe.vmoptions
-Xmx2048m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
# Uninstall existing HAXM
cd %ANDROID_HOME%\extras\intel\Hardware_Accelerated_Execution_Manager
silent_install.bat -u
# Download latest HAXM
# Install with custom settings
silent_install.bat -log -m 2048
# PowerShell (Admin)
# Enable Hyper-V
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
# OR Disable if using HAXM
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
# Check Vulkan installation
Get-ChildItem -Path C:\Windows\System32\vulkan* -File
Get-ChildItem -Path C:\Windows\SysWOW64\vulkan* -File
如果缺失:
C:\VulkanSDK\[version]\Bin
# Clean Android Studio
File → Invalidate Caches / Restart
# Update SDK Tools
sdkmanager --update
<!-- In gradle.properties -->
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m
org.gradle.parallel=true
org.gradle.daemon=true
# Check emulator process
tasklist | findstr "qemu"
# Monitor GPU usage
nvidia-smi -l 1
如果问题仍然存在:
# PowerShell
systeminfo | Select-String "Total Physical Memory","Processor","OS Name"
# Command Prompt (Admin)
systeminfo | findstr /i "Virtualization"
# Check emulator logs
type %USERPROFILE%\.android\avd\*.log
# Remove Android Studio completely
Remove-Item -Recurse -Force "${env:LOCALAPPDATA}\Google\AndroidStudio*"
Remove-Item -Recurse -Force "${env:APPDATA}\Google\AndroidStudio*"
记住:
您希望我更详细地解释任何特定部分吗?