Setup Android Studio Emulator for AMD Ryzen CPUs

May 5, 2020

1,196 words

Post contents

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.

BIOS Setup

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.

SVM Mode

To enable SVM mode, first start at the first screen to the left, labeled "M.I.T".

The MIT menu item

Then, select "Advanced Frequency Settings".

The Advanced Frequency Settings page

Finally, open the "Advanced CPU Core Settings".

The CPU Core settings page

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

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".

The chipset tab

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".

The "run dialog" box with the typed suggestion

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.

The startup screen showing "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)"

The mentioned screen with the AMD hypervisor selected

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:

SDK_INSTALL_LOCATION\extras\google\Android_Emulator_Hypervisor_Driver
The location of the hypervisor visually using OneCommander app

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.

The Win+X dialog The "Success" of the installer once ran

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

AVD Setup

To run the emulator, you need to set up a device itself. You do this through the "AVD Manager" in the "configure" menu.

The AVG manager submenu

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:

The three devices as mentioned

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.

The "select hardware" screen as mentioned

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.

The selected image for x86_64 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.

Naming the emulator device

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.

The emulator once ran

Conclusion

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!

Subscribe to our newsletter!

Subscribe to our newsletter to get updates on new content we create, events we have coming up, and more! We'll make sure not to spam you and provide good insights to the content we have.