Visual Studio Emulator and Android 7 or higher

Hinweis: Dieser Beitrag ist nur auf Englisch verfügbar

This post is about how to debug Android with using Hyper-V to debug Android 7 or higher machines in Visual Studio. This is a scenario because it is not possible to use the Intel HAXM virtualization driver in parallel with Hyper-V but this driver is required to run a performant Android emulated machine using the official Android emulator.

So here is how to debug Android version that are not available in the “Visual Studio Emulator for Android” set of machines.
First you need to download Android by using the Android x86 project as a source: http://www.android-x86.org/download
Download the Android version of your favor.

While downloading, you can create a new Hyper-VM. The important step is, that you disable Secure Boot in the “Security” section. You can use a Gen2 machine (tested with Android 7.1). You also have to select an External Network adapter that has access to the internet. Otherwise you will have problems to configure the virtual Android later on.

When your download is done, you can mount the ISO to the virtual DVD-driver of your VM and start the VM. Follow the dialog to setup the VM until you are at the desktop of your Android VM.
Remark: the usage of the cursor is pretty strange. You can only move it when you click the mouse button. But this also results in a swipe gesture. I haven’t found another way of moving the cursor without clicking. Using the latest Release 7.1 R2 fixes this issue.

When you are at the desktop of the Android VM, you can open the main Menu and open the “Termial Emulator” to get a command prompt. Enter “ifconfig” to show the IP of your VM. Switch to Visual Studio. I expect you have the “Visual Studio Emulator for Android” installed, so you have the control buttons in the toolbar. Click the button, that opens the Android Adb command prompt.

 

 

Type the following command in this prompt:

adb connect <ip of VM>

(i.e. “adb connect 192.168.0.127”)

You should see the message “connected to <ip>:5555”
You can verify the connect by executing “adb devices” and you should see your VM in this list.
Additionally you should have an entry called “Microsoft Corporation Virtual Machine (…)” in your “Start Debugging” combobox that lists all your devices available for debugging.

 

 

Now you can start debugging almost every version of Android that is available. Have fun with it!

Hint: If your VM goes to sleep, hold any of the arrow keys for a while (let’s say 30 sec) and connect it again via Adb Command Prompt.

Leave a Reply