我想用我的 api 运行 WSL2,并用一个 Android 模拟器来运行我的应用程序,这样我就可以测试所说的 api.当我激活 Hyper-V 时,WSL2 运行良好.然后我尝试使用 Android Studio 的模拟器,它只是挂起,从不启动模拟器.
I would like to run WSL2 with my api in it, and an Android emulator to run my app so I can test said api. WSL2 is working perfectly when I'm having Hyper-V activated. Then I'm trying to use Android Studio's emulator and it just hangs, never launching the emulator.
现在,如果我完全停用 Hyper-V(在 Windows 功能屏幕中并通过 bcdedit/set hypervisorlaunchtype off
)模拟器确实可以完美启动,但是 WSL2 现在当然不能工作了..
Now, if I deactivate Hyper-V entirely (in the windows features screen and through bcdedit /set hypervisorlaunchtype off
) the emulator does launch perfectly, but of course WSL2 won't work now...
我在这里查看了很多主题,但没有成功.例如 如何运行 Android 模拟器windows 同时使用带有 zsh 的 WSL2?,在 WSL 中使用直接在 Windows 中运行的模拟器运行 React Native 或 本教程一个>.目前没有成功.
I took a look at lots of the topics around here without success. For example How to run Android emulator on windows while using WSL2 with zsh?, Running React Native in WSL with the emulator running directly in Windows or this tutorial. No success so far.
如前所述,我正在使用 Ryzen 处理器.
As said I'm using a Ryzen processor.
我找到了解决办法.我正在运行 Windows 11 Pro,更新 21H2,操作系统版本 22000.51,AMD.
I was able to find way around it. I'm running Windows 11 Pro, Update 21H2, OS build 22000.51, AMD.
这里是 Google 文档如何设置模拟器AMD 处理器.它需要禁用 Hyper-V 和 WHPX.这与运行 WSL2 不匹配.
Here is Google documentation how to setup emulator for AMD processors. It requires Hyper-V and WHPX to be disabled. And that does not go in pair with running WSL2.
我的设置是:
我做了什么:
adb connect <ip going here>:5555
我尝试从 Ubuntu adb connect 到 Android,但它不能开箱即用.应该可以使用一些 WSL2 >主机重定向,但我目前不需要它,也没有进一步研究.
I tried to adb connect to the Android from Ubuntu, but it does not work out of the box. Should be doable with some WSL2 > Host redirects, but I currently do not need it and did not research it any further.
最后困扰我的是默认的 Android VM 分辨率(看起来像水平方向的平板电脑).可以像这样调整它.
Last thing that bugged me was default Android VM resolution (looks like tablet in horizontal orientation). It is possible to adjust it like that.
我们可能需要等待 Google 推出使用与 WSL2 相同的仿真类型的模拟器.
We probably need to wait for Google to come up with emulator that uses the same emulation type as WSL2.
不起作用/丢失的东西(或者我不知道该怎么做):
Things that do not work/are missing (or I do not know how to do it):
这篇关于使用 Ryzen 处理器同时运行 WSL2 和 Android Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!