Android emulator troubleshooting

This article describes the most common warning messages and issues that occur while configuring and running the Android Emulator. Also, it describes solutions for resolving these errors and various troubleshooting tips to help you diagnose emulator problems.

Deployment issues on Windows

Some error messages may be displayed by the emulator when you deploy your app. The most common errors and solutions are explained here.

Deployment errors

If you see an error about a failure to install the APK on the emulator or a failure to run the Android Debug Bridge (adb), verify that the Android SDK can connect to your emulator. To verify emulator connectivity, use the following steps:

  1. Launch the emulator from the Android Device Manager (select your virtual device and select Start).

  2. Open a command prompt and go to the folder where adb is installed. If the Android SDK is installed at its default location, adb is located at C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe; if not, modify this path for the location of the Android SDK on your computer.

  3. Type the following command:

    adb devices
    
  4. If the emulator is accessible from the Android SDK, the emulator should appear in the list of attached devices. For example:

    List of devices attached
    emulator-5554   device
    
  5. If the emulator doesn't appear in this list, start the Android SDK Manager, apply all updates, then try launching the emulator again.

MMIO access error

If the message An MMIO access error has occurred is displayed, restart the emulator.

Missing Google Play Services

If the emulated Android device doesn't have Google Play Services or Google Play Store installed, you probably created a virtual device that excluded these packages. When you create a virtual device, be sure to select one or both of the following options:

  • Google APIs—includes Google Play Services in the virtual device.
  • Google Play Store–includes Google Play Store in the virtual device.

For example, this virtual device will include Google Play Services and Google Play Store:

Android Device Manager with Google Play Services and Play Store enabled for .NET MAUI.

Note

Google Play Store images are available only for some base device types such as Pixel, Pixel 2, Nexus 5, and Nexus 5X.

Performance issues

Performance issues are typically caused by one of the following problems:

  • The emulator is running without hardware acceleration.
  • The virtual device running in the emulator using an Arm-based image.

The following sections cover these scenarios in more detail.

Hardware acceleration isn't enabled

When you start a virtual device, and you don't have hardware acceleration enabled, the Device Manager displays an error dialog similar to the following image:

Android device manager warning about Hyper-V not enabled on .NET MAUI.

To fix this error, follow the troubleshooting steps in the Hardware acceleration issues section.

Hardware acceleration issues

When using hardware acceleration, you may run into configuration problems or conflicts with other software on your computer. The first step in troubleshooting is verifying that hardware acceleration is enabled. You can use the Android's SDK to check this setting. Open a command prompt and entering the following command:

"C:\Program Files (x86)\Android\android-sdk\emulator\emulator-check.exe" accel

This command assumes that the Android SDK is installed at the default location of C:\Program Files (x86)\Android\android-sdk. If the Android SDK is installed elsewhere, modify the preceding command to the correct location.

Tip

Make sure the Android Emulator is up to date. From Visual Studio, press Tools > Android > Android SDK Manager. Select the Tools tab and see if the Android Emulator entry has an update available.

Hardware acceleration not available

If Hyper-V is available, a message like the following example will be returned from the emulator-check.exe accel command:

HAXM isn't installed, but Windows Hypervisor Platform is available.

If HAXM is available, a message like the following example will be returned:

HAXM version 6.2.1 (4) is installed and usable.

If hardware acceleration isn't available, a message like the following example will be displayed (the emulator looks for HAXM if it's unable to find Hyper-V):

HAXM isn't installed on this machine

If hardware acceleration isn't available, see Enabling Hyper-V acceleration to learn how to enable hardware acceleration on your computer.

Incorrect BIOS settings

If the BIOS hasn't been configured properly to support hardware acceleration, a message similar to the following example will be displayed when you run the emulator-check.exe accel command:

VT feature disabled in BIOS/UEFI

To correct this problem, reboot into your computer's BIOS and enable the following options:

  • Virtualization Technology (may have a different label depending on motherboard manufacturer).
  • Hardware Enforced Data Execution Prevention.

If problems still occur because of issues related to Hyper-V and HAXM, see the following section.

Hyper-V issues

In some cases, enabling both Hyper-V and Windows Hypervisor Platform in the Turn Windows features on or off dialog may not properly enable Hyper-V. To verify that Hyper-V is enabled, use the following steps:

  1. Enter PowerShell in the Windows search box.

  2. Right-click Windows PowerShell in the search results and select Run as administrator.

  3. In the PowerShell console, enter the following command:

    Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online
    

    If Hyper-V isn't enabled, a message similar to the following example will be displayed to indicate that the state of Hyper-V is Disabled:

    FeatureName      : Microsoft-Hyper-V-All
    DisplayName      : Hyper-V
    Description      : Provides services and management tools for creating and running virtual machines and their resources.
    RestartRequired  : Possible
    State            : Disabled
    CustomProperties :
    
  4. In the PowerShell console, enter the following command:

    Get-WindowsOptionalFeature -FeatureName HypervisorPlatform -Online
    

    If the Hypervisor isn't enabled, a message similar to the following example will be displayed to indicate that the state of HypervisorPlatform is Disabled:

    FeatureName      : HypervisorPlatform
    DisplayName      : Windows Hypervisor Platform
    Description      : Enables virtualization software to run on the Windows hypervisor
    RestartRequired  : Possible
    State            : Disabled
    CustomProperties :
    

If Hyper-V or HypervisorPlatform aren't enabled, use the following PowerShell commands to enable them:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All

After these commands complete, reboot.

For more information about enabling Hyper-V (including techniques for enabling Hyper-V using the Deployment Image Servicing and Management tool), see Install Hyper-V.

HAXM issues

HAXM issues are often the result of conflicts with other virtualization technologies, incorrect settings, or an out-of-date HAXM driver.

HAXM process isn't running

If HAXM is installed, you can verify that the HAXM process is running by opening a command prompt and entering the following command:

sc query intelhaxm

If the HAXM process is running, you should see output similar to the following result:

SERVICE_NAME: intelhaxm
    TYPE               : 1  KERNEL_DRIVER
    STATE              : 4  RUNNING
                            (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
    WIN32_EXIT_CODE    : 0  (0x0)
    SERVICE_EXIT_CODE  : 0  (0x0)
    CHECKPOINT         : 0x0
    WAIT_HINT          : 0x0

For information about troubleshooting HAXM, see Troubleshooting in the HAXM wiki.

HAXM virtualization conflicts

HAXM can conflict with other technologies that use virtualization, such as Hyper-V, Windows Device Guard, and some antivirus software:

  • Hyper-V—If you're using a version of Windows before the Windows 10 April 2018 update (build 1803) and Hyper-V is enabled, follow the steps in Disabling Hyper-V so that HAXM can be enabled.

  • Device Guard—Device Guard and Credential Guard can prevent Hyper-V from being disabled on Windows machines. To disable Device Guard and Credential Guard, see Disabling Device Guard.

  • Antivirus Software—If you're running antivirus software that uses hardware-assisted virtualization (such as Avast), disable or uninstall this software, reboot, and retry the Android emulator.

Incorrect BIOS settings for HAXM

On Windows, HAXM won't work unless virtualization technology (Intel VT-x) is enabled in the BIOS. If VT-x is disabled, you'll get an error similar to the following when you attempt to start the Android Emulator:

This computer meets the requirements for HAXM, but Intel Virtualization Technology (VT-x) isn't turned on.

To correct this error, boot the computer into the BIOS, enable both VT-x and SLAT (Second-Level Address Translation) and restart the computer.

Disabling Hyper-V

If you're using a version of Windows before the Windows 10 April 2018 Update (build 1803) and Hyper-V is enabled, you must disable Hyper-V and reboot your computer to install and use HAXM. If you're using Windows 10 April 2018 Update (build 1803) or later, Android Emulator version 27.2.7 or later can use Hyper-V (instead of HAXM) for hardware acceleration, so it isn't necessary to disable Hyper-V.

You can disable Hyper-V from the Control Panel by following these steps:

  1. Enter windows features in the Windows search box and select Turn Windows features on or off in the search results.

  2. Uncheck Hyper-V:

    Disable Hyper-V in the Windows Feature dialog for .NET MAUI.

  3. Restart the computer.

Alternately, you can use the following PowerShell command to disable the Hyper-V Hypervisor:

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor

Intel HAXM and Microsoft Hyper-V can't both be active at the same time. Unfortunately, there's no way to switch between Hyper-V and HAXM without restarting your computer.

It's possible that the preceding steps won't succeed in disabling Hyper-V if Device Guard and Credential Guard are enabled. If you're unable to disable Hyper-V, or it seems to be disabled but HAXM installation still fails, use the steps in the next section to disable Device Guard and Credential Guard.

Disabling Device Guard

Device Guard and Credential Guard can prevent Hyper-V from being disabled on Windows machines. This situation is often a problem for domain-joined machines that are configured and controlled by an owning organization. On Windows 10, use the following steps to see if Device Guard is running:

  1. Enter System info in the Windows search box and select System Information in the search results.

  2. In the System Summary, look to see if Device Guard Virtualization based security is present and is in the Running state:

    Check if Device Guard is running for .NET MAUI.

If Device Guard is enabled, use the following steps to disable it:

  1. Ensure that Hyper-V is disabled (under Turn Windows Features on or off) as described in the previous section.

  2. In the Windows Search Box, enter gpedit.msc and select the Edit group policy search result. These steps launch the Local Group Policy Editor.

  3. In the Local Group Policy Editor, navigate to Computer Configuration > Administrative Templates > System > Device Guard:

    Check if Device Guard is enabled in the Local Group Policy editor for .NET MAUI.

  4. Change Turn On Virtualization Based Security to Disabled (as shown above) and exit the Local Group Policy Editor.

  5. In the Windows Search Box, enter cmd. When Command Prompt appears in the search results, right-click Command Prompt and select Run as Administrator.

  6. Copy and paste the following commands into the command prompt window (if drive Z: is in use, pick an unused drive letter to use instead):

    mountvol Z: /s
    copy %WINDIR%\System32\SecConfig.efi Z:\EFI\Microsoft\Boot\SecConfig.efi /Y
    bcdedit /create {0cb3b571-2f2e-4343-a879-d86a476d7215} /d "DebugTool" /application osloader
    bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} path "\EFI\Microsoft\Boot\SecConfig.efi"
    bcdedit /set {bootmgr} bootsequence {0cb3b571-2f2e-4343-a879-d86a476d7215}
    bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} loadoptions DISABLE-LSA-ISO,DISABLE-VBS
    bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} device partition=Z:
    mountvol Z: /d
    
  7. Restart your computer. On the boot screen, you should see a prompt similar to the following message:

    Do you want to disable Credential Guard?

    Press the indicated key to disable Credential Guard as prompted.

  8. After the computer reboots, check again to ensure that Hyper-V is disabled (as described in the previous steps).

If Hyper-V is still not disabled, the policies of your domain-joined computer may prevent you from disabling Device Guard or Credential Guard. In this case, you can request an exemption from your domain administrator to allow you to opt out of Credential Guard. Alternately, you can use a computer that isn't domain-joined if you must use HAXM.

More troubleshooting tips

The following suggestions are often helpful in diagnosing Android emulator issues.

Starting the emulator from the command line

If the emulator isn't already running, you can start it from the command line (rather than from within Visual Studio) to view its output. Typically, Android emulator AVD images are stored at the following location: %userprofile%\.android\avd.

You can launch the emulator with an AVD image from this location by passing in the folder name of the AVD. For example, this command launches an AVD named Pixel_API_27:

"C:\Program Files (x86)\Android\android-sdk\emulator\emulator.exe" -partition-size 2000 -no-boot-anim -verbose -feature WindowsHypervisorPlatform -avd pixel_5_-_api_30 -prop monodroid.avdname=pixel_5_-_api_30

This command assumes that the Android SDK is installed at the default location of C:\Program Files (x86)\Android\android-sdk. If the Android SDK is installed elsewhere, modify the preceding command to the correct location.

When you run this command, it produces many lines of output while the emulator starts up. Specifically, lines such as the following example are printed if hardware acceleration is enabled and working properly. In this example, HAXM is used for hardware acceleration:

emulator: CPU Acceleration: working
emulator: CPU Acceleration status: HAXM version 6.2.1 (4) is installed and usable.

Viewing Device Manager logs

Often you can diagnose emulator problems by viewing the Device Manager logs. These logs are written to the following location: %userprofile%\AppData\Local\Xamarin\Logs\16.0.

You can view each DeviceManager.log file by using a text editor such as Notepad. The following example log entry indicates that HAXM wasn't found on the computer:

Component Intel x86 Emulator Accelerator (HAXM installer) r6.2.1 [Extra: (Intel Corporation)] not present on the system