История о том, как запустить эмулятор Android или сэкономить на процессоре intel
Предыстория
Я собрал года 4 назад домашний комп, который подходил всем моим запросам. На процессоре решил сэкономить — взял amd. К компу вопросов нет.
Потом занялся разработкой под Android и тут меня ждал сюрприз! Эмулятор запускался только на процессоре intel. Его можно было запустить без аппаратной виртуализации конечно, используя вот этот совет www.youtube.com/watch?v=QTbjdBPKnnw&t=127s, но кто пользовался знает, что эмулятор может запускаться очень долго. У меня с 12ГБ доходило до 10 мин. Это может конечно из-за встроенной видеокарты.
Основное рабочее место у меня было в офисе, поэтому особо переживал и тестировал дома на реальных устройствах. Но пару месяцев назад стал нужен именно эмулятор. Первой мыслью было конечно купить intel-овский процессор. Но нужно было покупать ещё материнскую плату и видеокарту. Скорее всего я бы так и поступил, если бы не наткнулся на обновлённые требования к системе. В требованиях написано, что эмулятор всё таки можно запустить на Windows 10 (с обновлениями после апреля 2018) с помощью технологии WHPX.
Теперь основная часть истории, как это сделать. Всё оказалось не так тривиально. Заранее прошу прощения за упущения, потому что не могу назвать себя знатоком ни в “железе”, ни в Windows.
Инструкция
После всех обновлений эмулятор естественно не запустился. AndroidStudio пыталась запустить эмулятор с помощью HAXM и выбрасывала ошибку “Emulator: emulator: ERROR: x86 emulation currently requires hardware acceleration!”.
Далее приведу инструкцию с ссылками упустив кучу подробностей и моих “танцев с бубном”.
Должен поддерживать для работы с аппаратной виртуализацией.
2. Обновляем Windows 10 до версии 1803 (апрель 2018):
4. Включаем в bios режим виртуализации. Он там может называеться IOMMU, а не VT.
5. Качаем обновления для bios с официального сайта. Для моего asus, например, они были здесь.
Версия Bios должна стать что-то около 3001:
7. Заходим на сайт microsoft и изучаем инструкцию для включения компонента.
8. Нужно проверить требования Hyper-V. Для этого в командной строке набираем systeminfo. Проверяем, чтобы отображались эти значения:
У меня же вместо это было сообщение:
На официальном сайте написано, что пока не будет стоять Yes-Yes-Yes-Yes система WHPX не будет работать. У меня же эмулятор запускается, при включенной низкоуровневой оболочке.
9. Далее в руководстве предлагается включить компонент hyper-v (он по умолчанию отключен):
В русском переводе наименования несколько отличаются:
Кстати, после отключения компонента “Платформа низкоуровневой оболочки Windows”, “Требования hyper-v” становятся Yes-Yes-Yes-Yes. Не понял этот момент. Если кто разбирается, напишите в комментариях.
10. Определяем, нужно ли нам всё это? Или легче было купить intel)
После этих настроек всё должно заработать:
Хочу отметить, используя технологию WHPX и процессор amd, запуск эмулятора занимает примерно столько же времени, сколько на процессоре intel. Учитывая, что остальное «железо» сравнимо по своим параметрам.
Источник
Amd and android emulator
Android Emulator Hypervisor Driver for AMD Processors
Android Emulator Hypervisor Driver for AMD Processors is a hypervisor to accelerate Android Emulator. It is made by porting KVM to Windows (Windows 7 or later, 64bit).
Android Emulator Hypervisor Driver for AMD Processors runs as a Windows driver. User space support for Android Emulator Hypervisor Driver for AMD Processors is available from Android Emulator.
Download and Install
Android Emulator Hypervisor Driver for AMD Processors is released through android-studio. However, only Android Studio with version 4.0 canary 5 or above can both download and install/update the driver. Otherwise, the Android Studio will only download the driver package without performing installation. In the latter case, users are required to install the driver manually.
- CPU has virtualization extension and BIOS has NOT disabled the extension.
- Hyper-V must be disabled. Refer to this page for more information.
Use an administrator command console to execute «silent_install.bat» inside the driver package. Make sure you see the desired output from the installer: STATE: 4 RUNNING
If you would like to contribute a patch to the code base, please read these guidelines.
Reporting an Issue
You are welcome to file an issue at Issuetracker. Please remember to supply your OS information, CPU model in addition to details on the issue.
A patched QEMU can be found here at github. However, there is no support for it. Use at your own risk.
As its name suggests, Android Emulator Hypervisor Driver for AMD Processors is developed and tested on AMD platform. We only make our best effort in keeping Intel Processor support.
Источник
Setup Android Studio Emulator for AMD Ryzen CPUs
by Corbin Crutchley
In the past, Android Studio did not support AMD’s CPUs for hardware emulation of an Android device. That all changed in 2018 when Google added Hyper-V support to the Android Emulator.
However, while working on my Ryzen CPU powered desktop, I had difficulties getting the program working on my machine.
To use Hyper-V, we have to have various settings configured on our motherboards.
Two of the settings we need to enable are:
- IOMMU — Provides resources to be passed directly to virtual machines
- SVM Mode — «Secure Virtual Machine» features, enabling applications to use features for VMs
I personally have a Gigabyte motherboard (the Gigabyte GA-AB350M-Gaming 3), so I’ll showcase the places I had to find the options for these motherboard settings.
To enable SVM mode, first start at the first screen to the left, labeled «M.I.T».
Then, select «Advanced Frequency Settings».
Finally, open the «Advanced CPU Core Settings».
Once on this page, you should see «SVM Mode» as the fourth option from the bottom. Toggle that to «Enabled», then move onto enabling IOMMU
Enabling IOMMU on a Gigabyte AMD motherboard is much easier than enabling SVM mode. Simply go to the «Chipset» root tab, and it should be the first option at the top. Even if it’s set to «Auto», go ahead and update that to be «Enabled».
Once changed, tab over to «Save & Exit» and select «Exit and save changes».
Windows Features Setup
Now that we have our BIOS (UEFI, really) configured correctly, we can enable the Windows features we need for the Android Emulator.
To start, press Win + R , which should bring up the «Run» dialog. Once open, type OptionalFeatures and press «OK».
Once that’s run, you’ll see a «Turn Windows features on or off» window.
You’ll want to turn on the following options:
- Hyper-V
- Windows Hypervisor Platform
- Windows Sandbox
After these three settings are selected, press «OK» and allow the features to install. After your features are installed, your machine will need a reboot. Go ahead and restart your computer before proceeding to install Android Studio.
Setup Android Studio
You have a few different methods for installing Android Studio. You can choose to use Google’s installer directly, you can utilize the Chocolatey CLI installer, or even use JetBrain’s Toolbox utility to install and manage an instance of Android Studio. Any of these methods work perfectly well, it’s down to preference, really.
Once you get Android Studio installed, go ahead and open the SDK Manager settings screen from the «Configure» dropdown.
Once you see the popup dialog, you’ll want to select the «SDK Tools» tab. There should be a selection of tools that you can install or update. One of those selections (in about the middle of the list) should be called «Android Emulator Hypervisor Driver for AMD Processors (installer)»
Once you’ve selected it, press «Apply» to download the installer. Because the «Apply» button only downloads the installer, we’ll need to run it manually.
Run the Installer
To find the location of the installer, you’ll want to go to the install location for your Android SDK. For me (who used the Jetbrains Toolbox to install Android Studio), that path was: %AppData%/../Local/Android/Sdk .
The hypervisor installer is located under the following subpath of that path:
If you like having this macOS-like preview pane of files, you can find it in the OneCommander application. We covered this app in our «Ultimate Windows Development Environment Guide» article
Once you have the path located, you’ll want to run the silent_installer.bat inside of an elevated shell. I did this by pressing Win + X and pressing «Windows PowerShell (Admin)». Once that was opened, I copied the path to the PowerShell window via cd and ran the installer.
You should see the message «DeleteService SUCCESS» if everything ran as expected.
If you get an error [SC] StartService FAILED with error 4294967201. , make sure you’ve followed the steps to enable BOTH settings in your BIOS as well as ALL of the features mentioned in Windows
To run the emulator, you need to set up a device itself. You do this through the «AVD Manager» in the «configure» menu.
You’ll then see a list of the devices that you currently have setup. I, for example, have three different devices already setup as you can see here:
You can create a new one by pressing «Create Virtual Device».
Upon the dialog creation, you’ll see a list of devices that you can use as a baseline for your emulator. This sets the hardware information (screen size and such). Even if you pick a device, it does not restrict the versions of Android you can use with it. I picked Pixel 2 and KitKat for my KK testing device, despite the Pixel 2 being released well after that OS release.
Once you’ve selected a device, you can pick the version of Android to run. You’ll want to select an x86 or x86_64 build of Android you’re looking for. I’ve noticed better performance from x86_64 emulators myself, so I went with an x86_64 build of Android Pie.
Afterward, you’ll want to name your emulator. I try to keep them without strings and not too long, so if I need to run the emulator manually in the CLI, I can do so with the name of the emulator easily.
Finally, once you’ve selected «Finish», it should save the emulator’s settings and start the emulator itself.
You may get an error such as HAXM is not installed when trying to set up an emulator. If you get this error, it’s most likely that you have not enabled the settings in BIOS. I know in my case, I had recently performed a BIOS upgrade, and it had reset my BIOS settings, making me go back and re-enable them.
I’ve had incredible success with my Ryzen powered desktop during my Android development. Not only is it cost-efficient for my usage compared to the Intel option, but it’s able to run the emulator quickly. Hopefully, this article has been able to help you set up your machine as well.
Let us know what your thoughts on this article were! We not only have our comments down below, but we have a Discord community as well that we invite you to join! We chat about all kinds of programming and CS related topics there!
Источник