Running Android emulator on WSL-2

I'm running android studio & emulator on WSL-2 it reports that the emulator is out of date even though the version number is 30.9.5.0 (build_id 7820599), anyone know why? Also emulator eventaully crashes, any suggestions on best way to debug or who I can work with on this?

mwoodpatrick@MarkSpectre14:/mnt/c/Users/mlwp$ /home/mwoodpatrick/Android/Sdk/emulator/emulator -avd Pixel_C_API_30
INFO | Android emulator version 30.9.5.0 (build_id 7820599) (CL:N/A)
WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
WARNING | cannot add library /home/mwoodpatrick/Android/Sdk/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
INFO | added library /home/mwoodpatrick/Android/Sdk/emulator/lib64/vulkan/libvulkan.so
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
INFO | configAndStartRenderer: setting vsync to 60 hz
INFO | Started GRPC server at 127.0.0.1:8554, security: Local
INFO | Advertising in: /mnt/wslg/runtime-dir/avd/running/pid_29639.ini
INFO | 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"
INFO | boot completed
INFO | boot time 130958 ms
INFO | Increasing screen off timeout, logcat buffer size to 2M.
INFO | Revoking microphone permissions for Google App.
Segmentation fault
 

Mark WoodPatrick

Lurker
Thread starter
I downloaded the android SDK and build and ran the tests and they all passed. When I ran the emulator under gdb it turns out the failure was "libc++abi: terminating with uncaught exception of type std::__1::system_error: random_device failed to open /dev/urandom: Too many open files". Reviewing the code it seems that the apple build checks if it can open 16k files but the Linux version does not, seems like this is an issue on WSL-2 but there is a workaround windows subsystem for linux - How can I raise the limit for open files in Ubuntu 20.04 on WSL2? - Stack Overflow I will give this a try and see how it goes. Why do we need so many open files? Is there any architectural documentation on the emulator all I could find so far has been the help that is useful? I Will update as I discover more
 

Mark WoodPatrick

Lurker
Thread starter
Fixing the maximum number of open files "via ulimit -n" fixed my crash but emulator still hangs so I installed the windows version and it also hangs. Has anyone else gotten the android emulator to run on windows 11 with hyper-V enabled? Any suggestions on how to debug?
 

Mark WoodPatrick

Lurker
Thread starter
Running without hw acceleration:

C:\Users\mlwp\AppData\Local\Android\Sdk\emulator> .\emulator.exe -avd Pixel_C_API_30 -no-accel -show-kernel

got further.

Running on the command line with hw accel I see "failed to initialize WHPX: Invalid argument"

PS C:\Users\mlwp\AppData\Local\Android\Sdk\emulator> .\emulator.exe -avd Pixel_C_API_30 -show-kernel
INFO | Android emulator version 30.9.5.0 (build_id 7820599) (CL:N/A)
WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
INFO | added library vulkan-1.dll
INFO | configAndStartRenderer: setting vsync to 60 hz
ERROR | Failed to open /qemu.conf, err: 2
C:\Users\mlwp\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: WHPX: Failed to setup partition, hr=c0350005
C:\Users\mlwp\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: failed to initialize WHPX: Invalid argument
 
Top