Setup Android Emulators for Windows

The Visual Studio Emulator for Android is a desktop application that emulates an Android device. It provides a virtualized environment in which you can debug and test Android apps without a physical device. It also provides an isolated environment for your application prototypes.

The Visual Studio Emulator for Android is designed to provide comparable performance to an actual device. Before you publish your app, however, we recommend that you test your app on a physical device.

You can test your app on a unique device profile for each of the Android platforms, screen resolutions, and other hardware properties supported by Visual Studio Emulator for Android.

Installing

Visual Studio Emulator for Android is a component of the cross-platform tools available in Visual Studio and will be installed during a custom Visual Studio setup when you select Cross-Platform Mobile Development, then Common Tools and Software Development Kits, and then Visual Studio Emulator for Android.

Uninstalling

You can uninstall the Visual Studio Emulator for Android using Add/Remove Programs in the Control Panel.

System_CAPS_noteNote

Uninstalling Visual Studio will not uninstall the emulator. You must uninstall the emulator separately.

When you uninstall the Visual Studio Emulator for Android, the Hyper-V Virtual Ethernet Adapters that were created for the emulator to use are not automatically removed. You can manually remove these virtual adapters (if not in use) by opening Hyper-V Manager, selecting one of the emulator VHD images, choosing the Networking tab, and choosing Remove for each of the switches that appears in this tab.

System Requirements and backward compatibility

Visual Studio Emulator for Android runs as a virtual machine on Hyper-V, the virtualization technology for Windows 8 and later versions. To run the emulator, your computer must meet the requirements to run Hyper-V as described in this topic.

The setup program tries to configure these prerequisites for you silently when you install the emulator. When setup successfully configures the prerequisites, the emulator simply works as expected. Otherwise you may have to enable these prerequisites manually. If you have to configure the prerequisites manually, the steps and tools are the same steps described here for the Windows Phone Emulator.

System_CAPS_importantImportant

The setup program for the emulator checks the prerequisites for running Visual Studio Emulator for Android. It displays warnings if the prerequisites are not present, but it does not require them.

Here is a quick checklist of the requirements for running the Visual Studio Emulator for Android. For more detailed info, see the subsequent sections in this topic.

System requirements

  • Hyper-V support (see Hyper-V requirements below)

  • 6 GB or more of RAM.

  • 64-bit version of the Pro edition of Windows 8, Windows 8.1, Windows10 or higher

  • A processor that supports SSSE3 or later.

Network requirements

  • DHCP

  • Automatically configured DNS and gateway settings

Hyper-V requirements

  • In the BIOS, the following features must be supported:

    • Hardware-assisted virtualization

    • Second Level Address Translation (SLAT)

    • Hardware-based Data Execution Prevention (DEP)

  • In Windows, Hyper-V must be enabled and running.

  • You have to be a member of the local Hyper-V Administrators group.

Your computer must meet the following requirements:

  • Hyper-V support (see Hyper-V requirements)

  • 6 GB or more of RAM.

  • 64-bit version of the Pro edition of Windows 8, Windows 8.1, Windows10 or higher.

To check requirements for RAM and Windows, in Control Panel, choose System and Security, and then choose System.

Verify the system requirements
Network requirements
Your network must meet the following requirements:
  • DHCP

    The emulator requires DHCP because it configures itself as a separate device on the network with its own IP address.

  • Automatically configured DNS and gateway settings

    It’s not possible to configure DNS and gateway settings manually for the emulator.

To troubleshoot networking issues in the emulator, see the following topics:

Hyper-V requirements in the BIOS

Your computer’s BIOS must support the following requirements, and they must be enabled:

  • Hardware-assisted virtualization

  • Second Level Address Translation (SLAT)

  • Hardware-based Data Execution Prevention (DEP)

Hyper-V requirements in Windows

When your computer and BIOS settings are already configured to support Hyper-V, the setup program enables and starts Hyper-V. Otherwise you may have to enable these requirements manually.

Requirement

How to check and enable this requirement

Hyper-V must be installed

Follow the same instructions used to enable Hyper-V for the Windows Phone emulator.

Check the status of the Hyper-V Virtual Machine Management service in the Services snap-in.

Hyper-V must be running.

For more info about managing services, see the following topics:

You have to be a member of the local Hyper-V Administrators group.

To run the Visual Studio Emulator for Android without a recurring prompt to elevate your rights, you have to be a member of the local Hyper-V Administrators group. If you are already a local administrator on the computer when you install the SDK, the setup program for the SDK adds you to the Hyper-V Administrators group. Otherwise you may have to enable this requirement manually.

When you run the emulator, if you are not already a member of the Hyper-V Administrators group, you are prompted to join the group (the dialog box refers to the Windows Phone emulator). Joining the group requires administrator rights.

System_CAPS_importantImportant

After you join the group, log off or reboot to make the change take effect.

Joining the Hyper-V Administrators security group

To add yourself to a group manually, open the Local Users and Groups snap-in. For more information, see Add a user account to a group. (This Windows 7 topic is also applicable to Windows 8.)

If you try to run an app on the Visual Studio Emulator for Android while you are running Windows from a bootable VHD, the emulator typically takes several minutes to start or fails to start. When the emulator fails to start, you see the following message: App deployment failed. Please try again.

This configuration is not supported. For information about related issues, see Troubleshooting the Visual Studio Emulator for Android.

On a hard drive configured with the NTFS file system, the virtual hard disk files used by Hyper-V must be uncompressed and unencrypted. Make sure that the following directories are not compressed or encrypted:

  • %localappdata%\Microsoft\XDE

  • C:\Program Files (x86)\Microsoft Emulator Manager

  • C:\Program Files (x86)\Microsoft Visual Studio Emulator for Android

  • %localappdata%\Microsoft\VisualStudioEmulator

On the ReFS file system, the virtual hard disk files must not have the integrity bit set.

In order for the emulator to emulate calls to the GPU, such as those used by OpenGL ES, your machine must have a DirectX compatible GPU with appropriate DirectX drivers installed.

For important info about the hardware, software, and configuration requirements for Visual Studio Emulator for Android, see the following topic.

Visual Studio Emulator for Android requires Visual Studio 2015; it is not backward compatible with earlier versions of Visual Studio.

New versions of the emulator are installed on top of old versions (and may, in some cases, replace the old images, discarding the settings, apps, and files installed on those images).

The networking connection of the Visual Studio Emulator for Android behaves like the connection of a desktop computer with these characteristics:

  • The emulator appears on the network as a separate device with its own IP address.

  • It does not require any additional networking software that is not already installed with the emulator.

  • It is not joined to a Windows domain.

To understand the capabilities of the emulator's network connection, think of it as similar to a Wi-Fi connection from your Android phone to the same network. If an app running on your phone can access a network resource over its Wi-Fi connection, then an app running on the emulator can also access the same network resource.

For more info on network requirements, see System Requirements for the Visual Studio Emulator for Android

For info on troubleshooting networking issues, see Troubleshooting the Visual Studio Emulator for Android.

Testing your Android app for compatibility across the staggering variety of Android hardware can be a challenge. Android phones and tablets in the market span a wide range of versions and screen sizes and come in many different hardware configurations (RAM, CPUs, architecture, etc.). The Visual Studio Emulator for Android simplifies this using device profiles. Our set of device profiles represent the most popular hardware in the market, including devices from Samsung, Motorola, Sony, LG, and more.

In Visual Studio 2015, you can install, uninstall, and start device profiles using the Emulator Manager. Access the Emulator Manager by choosingTools, then Visual Studio Emulator for Android.

The Visual Studio Emulator for Android Manager

By default, there are four pre-installed device profiles (KitKat and Lollipop phone/5" and tablet/7" configurations), as indicated by the white text and icons. Other profiles in the list will appear grayed out until you choose the Install Profile button and the installation completes. You can filter the list by API Level and click the details arrow on the bottom right-hand side of a profile to view its full configuration details.

Once you've installed the set of profiles that you'd like to target, you can start these new profiles directly from the manager by pressing the greenPlay button. They will also appear in the debug target dropdown menu in any Visual Studio cross-platform mobile project type.

For detailed information on features you can test in the emulator, see this documentation.

The following list describes features of the Android platform that you cannot test in the emulator. You have to test these features on a physical device.

  • Compass

  • Gyroscope

  • Vibration controller

  • Brightness. Changing the brightness level of the emulator will not visually impact the way the device appears on your screen.

If your host computer meets the system requirements and you encounter an issue not covered in this troubleshooting guide:

  • Ask a question on StackOverflow using the android-emulator and the visual-studio tag.

  • Report an issue using the Send a Smile tool in Visual Studio or in the Emulator Manager.

 

This topic contains information to help you resolve issues that you may experience when you’re using the Visual Studio Emulator for Android.

System_CAPS_warningWarning

When the emulator is installed, the setup program checks the prerequisites for running the software. It displays warnings if the prerequisites are not present, but it does not require them for installation.

If you don't have Hyper-V installed, you will see the following message when you try to install the emulator. You must have a machine that supports HyperV and it must be enabled.

Android_Emu_Install_Issue
System_CAPS_noteNote

This message applies both to the Visual Studio Emulator for Android and the Windows Phone Emulator. Windows 8.1 and Windows 10 support the emulator.

Cannot connect to network destinations on a domain or corporate network

The Visual Studio Emulator for Android appears on the network as a separate device with its own IP address. It is not joined to a Windows domain and it does not share domain or workgroup credentials with the host computer.

If your network requires domain or workgroup authorization for basic network and Internet connectivity, contact your IT administrator for an exception. This exception allows your development computer to serve as a boundary machine and to accept connections from non-domain-joined network devices like the emulator.

The Visual Studio Emulator for Android also uses its own set of MAC addresses. If you can’t access network or Internet resources from the emulator, check with your IT administrator to make sure that the emulator’s MAC addresses have been authorized on your network.

To view the emulator’s MAC addresses

  1. Launch the emulator.

  2. On the emulator toolbar, click the chevron button (>>) to open the Additional Tools window.

  3. In the Additional Tools window, click the Network tab.

  4. On the Network page, locate the Physical address entries.

Cannot connect to network destinations when network settings require manual configuration
To connect to network destinations from the emulator, your network must meet the following requirements:
  • DHCP. The emulator requires DHCP because it configures itself as a separate device on the network with its own IP address.

  • Automatically configured DNS and gateway settings. It’s not possible to configure DNS and gateway settings manually for the emulator.

If your network requires manually configured settings, check with your IT administrator to determine how you can enable network connectivity for the emulator.

Under certain conditions, the emulator takes several minutes to start or fails to start due to a timeout. When the emulator fails to start, you see the following message: App deployment failed. Please try again. The following conditions can result in this error.

  • Running the Visual Studio Emulator for Android from a bootable VHD. This configuration is not supported.

  • A faulty hard drive. Consider running the chkdsk program.

  • A hard drive that needs to be defragmented. Consider defragmenting the drive.

  • A hard drive that is almost full. Check the space available on the drive.

  • Not enough memory is available because of other running applications. Reduce the number of applications that are consuming memory or increase the amount of memory.

  • Generally, any factor that is contributing to poor performance on the system. Begin troubleshooting with the component that has the lowest subscore in the Windows Experience Index, which you can find on the Performance Information and Tools page of Control Panel.

If the emulator was working previously, but does not work now, go through the following tasks. If you are using the emulator for the first time, seeEmulator fails to start (first use) before you try these steps.

  • Remove any other Hyper-V instances of the emulator.

    1. Close Visual Studio.

    2. Open Hyper-V Manager and stop any Hyper-V instances of the Emulator (Virtual Machines) that are already running and possibly in a corrupt state.

    3. In Hyper-V Manager, delete any other emulator VMs.

    4. Reboot your machine.

  • Make sure you have at least 4GB system memory and that it is not being consumed by other resource-intensive programs and processes (for example, try closing any browser windows).

  • In Hyper-V Manager, open the Virtual Switch Manager and check to see that you have two network switches; verify that the first one is the internal switch and the second is external.

    Android_Emu_V_Switch_Man

    If the setup is incorrect and you are using Windows 10, you might try to Reinstall network devices using netcfg –d command (section 6).

  • If these steps do not resolve the issue, see Emulator fails to start (first use) for information on 3rd party software that may be interfering with the emulator.

If the emulator does not start, go through the following tasks to identify and fix the issue.

  • Make sure that minimum hardware requirements are fulfilled and that BIOS settings are correct.

    The Emulator and Windows 8 Hyper-V require a 64-bit processor with Second Level Address Translation (SLAT). For Intel, you essentially need a Core i3, i5 or i7 processor (or one of many Xeons). A list of AMD chips is available here.

    1. Make sure your computer meets the system requirements.

    2. Verify that the SLAT tool reports that your computer is SLAT capable.

    3. Within the BIOS settings of your computer, make sure that all virtualization technology is enabled. The exact BIOS descriptions may vary for each hardware manufacturer. In general, enable features related to:

      • SLAT (Second Level Address Translation)

      • EPT (Extended Page Tables) (Intel)

      • NPT (Nested Page Tables) (AMD)

      • RVI (Rapid Virtualization Indexing) (AMD)

      • VMX (an Intel acronym indicating hardware assisted virtualization support)

      • SVM (an AMD acronym indicating hardware assisted virtualization support)

      • XD (Execute Disable) (Intel); this must be enabled

      • NX (No Execute)(AMD); this must be enabled.

    4. If the following options are present in the BIOS, disable them.

      • Disable Intel VT-d

      • Disable Trusted Execution

      For more information, see this article: Technet: Hyper-V: How to Fix BIOS Errors Enabling Hyper-V

    5. Make sure you have at least 4GB system memory and that it is not being consumed by other resource-intensive programs and processes.

    6. Make sure you are running Windows 8 Professional or better (Windows Server 2008 is not supported). Windows Server 2012 is supported, but you must enable Desktop Experience.

    You can inspect the Event Viewer to see if there are any Hypervisor errors. To do this, open Event Viewer (Start key + R, then type eventvwr) and then select Windows Logs, System. Then filter the log by event source, setting the source to Hyper-V-Hypervisor. Check for errors to help identify root cause.

    If your processor meets the minimum requirements but hypervisor is still failing, consider finding out if there is a BIOS upgrade available for your computer. If there is one, and you choose to upgrade, be sure to observe all precautions from the manufacturer when upgrading the BIOS (such as making sure the BIOS firmware upgrade is not interrupted by a power loss, which may permanently corrupt the BIOS).

  • Make sure you have at least 4GB system memory and that it is not being consumed by other resource-intensive programs and processes.

  • Remove/Disable third party drivers or software that may be interfering with virtual networking.

    There are some known issues with some 3rd party products installed under Windows 8 such as networking drivers/protocols that are not fully compatible with the Hyper-V networking stack.

    In general, it will be up to the developers of those products to update their software to be compatible with Windows 8 and Hyper-V.

    The following products may require upgrading for Windows 8 compliance: VirtualBox, Virtual PC 7, VMWare, some VPN clients, software firewalls, some versions of the Cisco VPN clients, and other virtualization systems. Work with the developer of the questionable virtualization software to encourage them to upgrade the software to make it compatible with Windows 8 and Hyper-V.

    As a Workaround, you can disable all third party drivers and applications which may be interfering with the virtual network used by the Emulator to communicate with Visual Studio. These applications may include:

    • Antivirus applications (which hook into the network stack)

    • Network monitoring tools

    • Network logging tools

    • Other system monitoring software

    Another possible workaround, short of uninstalling the product(s) in question (and requesting the product developer to release an updated version), is to take the following steps.

    1. Start the Network Connections manager (from the Start screen, type View Network Connections and select this option to view the network connections.)

    2. For the vEthernet (Internal Ethernet Port Windows Phone Emulator Internal Switch) adapter, choose Properties from the context menu.

      Virtual Adapter used by Hyper-V

      The adapter properties are shown here.

      Virtual Adapter Properties
    3. For this adapter, the only items that should be selected under This connection uses the following items should be the following:

      • Client for Microsoft Networks

      • QoS Packet Scheduler

      • File and Printer Sharing for Microsoft Networks

      • Microsoft LLDP Protocol Driver

      • Link-Layer Topology Discovery Mapper I/O Driver

      • Link-Layer Topology Discovery Responder

      • Internet Protocol Version 6 (TCP/IPv6)

      • Internet Protocol Version 4 (TCP/IPv4)

    4. Deselect any other items.

    The downside to using this technique is that any time a new 3rd party product installs unsupported drivers, or any time the emulator is installed, these steps will need to be repeated.

    After uninstalling third party products you may need to restore the Windows Phone Emulator Internal Switch. To do that:

    • Open Hyper V and go into the Virtual Switch Manager. Create a virtual switch named "Windows Phone Emulator Internal Switch" and set its connection type to Internal network.

      Virtual Switch Manager

    Now launch the emulator. It should work.

This problem can occur when the following conditions are true:

  • Your computer has a Gigabyte motherboard.

  • USB3 is enabled on the motherboard.

To solve this problem, disable USB3 in the BIOS settings of the motherboard and reboot the computer. Then check whether Gigabyte has released an update for your motherboard’s BIOS.

For more info, see the following Knowledge Base article: Boot failure after installation of Hyper-V role on Gigabyte systems.

If the emulator is running, but it does not appear to be connected to ADB (Android Debug Bridge) or it does not appear in Android tools that make use of ADB (for example, Android Studio or Eclipse), you may need to adjust where the emulator looks for ADB. The emulator uses a registry key to identify the base location of your Android SDK, and looks for the \platform-tools\adb.exe file under that directory. To modify the Android SDK path used by the emulator:

  • Open Registry Editor by selecting Run from the Start buttons context menu, typing regedit in the dialog box, and choosing OK.

  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools in the folder tree on the left.

  • Modify the Path registry variable to match the path to your Android SDK.

Restart the emulator and you should now be able to see the emulator connected to ADB and associated Android tools.

You may experience this issue due to incompatibility with Xamarin Player. If the emulator appears to hang or if you see this error message, "The emulator is unable to connect to the device operating system: Couldn’t set up the UDP port. Some functionality might be disabled", you may be experiencing this issue. Take the following steps.

  1. Uninstall Xamarin Player.

  2. Verify that virtual box has been removed (Xamarin Player runs on top of virtual box).

  3. Go to device manager, select the option to show hidden devices, and then delete everything except the physical network cards.

  4. You can try uninstalling/reinstalling Hyper-V after removing any non-physical network adapters.

If you are running Windows 10 with Intel Skylake processors, Xamarin apps might fail to run in the emulator or the Visual Studio debugger might not attach to them. This is due to an issue with Hyper-V and Skylake processors. Take the following steps as a workaround.

  1. Open Hyper-V Manager and select the VM for the emulator profile that your are using.

  2. Select Delete Saved State (lower right).

  3. Choose Settings...

  4. Expand the processor node and choose Compatibility.

  5. Enable Migrate to a physical computer with a different processor version.

  6. Restart the service (under Actions) and try again.

The emulator does not ship with the libraries for Google Play Services. However, the emulator does support drag-and-drop installation of flashable zip files.

The emulator uses ADB.exe to facilitate file transfer when you drag and drop a file onto the screen. If you encounter an error when you try to drag and drop a file, this probably indicates that the emulator is not connected to ADB.exe. To resolve, follow steps in Visual Studio gets stuck trying to deploy the app to the emulator or the emulator does not appear as a debug target in other IDEs.

If you take a screenshot using the Screenshot tab in the Additional Tools window and the resulting image is of an unexpected size, you may need to adjust the zoom level of the screen before choosing Capture. The emulator takes screenshots at the resolution of the screen on your host PC monitor.

The emulator renders OpenGL content using your host machine’s GPU and uses the ANGLE project to convert these calls to and from DirectX. If your application renders correctly on a device but incorrectly on the emulator, it is likely that the device is mitigating an incorrect OpenGL call (for example, using shader variables that do not match).

In some cases, the emulator will start and not respond to multi-touch either through direct interaction from your touch-enabled display or using the Multi-Touch Tool on the emulator toolbar. If this is the case, choose the Rotate button on the emulator toolbar and attempt to use multi-touch again. If the issue persists, read the Emulator fails to render OpenGL content issue.

No Comments

Add a Comment

As it will appear on the website

Not displayed

Your website