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:
- 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:
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.
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_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 installedwhen 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!