Installing Android on a Hyper-V virtual machine
Working with mobile device management (MDM) require a lot of
testing. With Windows 10 testing is no problem (except those things that demand
to be done on a physical device by different reasons), they can easily be run
virtual. But when it comes to phones and tablets it have not been that easy.
Visual Studio and some other solutions where out there, but they did not come
with Store access or they had dependence which excluded Hyper-V from running.
Some Emulators runs in a Hyper-V VM with Windows 10, but not on the host
itself. So, if you got it to work it was usually slow and painful.
The best solution was to run Virtual Box (or VMWare, but VM’s are usually available for Virtual Box first), and download pre-created VM’s from OsBoxes.org https://www.osboxes.org/android-x86/
I did try the same steps on an Android 6, but that one failed to start after a successful install. So, if you need to use version 6 or older of Android you should chose Virtual Box/VmWare or try to figure out a solution (and tell me).
The best solution was to run Virtual Box (or VMWare, but VM’s are usually available for Virtual Box first), and download pre-created VM’s from OsBoxes.org https://www.osboxes.org/android-x86/
These images are based on the work from the Android-X86
project http://www.android-x86.org/.
From this site you can download iso files to run Android on your PC. My
experience with running VM’s in Hyper-V with Android was that sometimes it
worked, but usually slow with many hangs or other errors or it just wouldn’t install
at all.
After seeing how well Android 7.1 run on a Virtual Box I
decided to try to get it to work on Hyper-V again. Hyper-V runs Windows much
better and I often work and demo the entire Office 365 and EM+S lifecycle, including
synchronise Active Directory to Azure and managing computer and devices with
Intune. After some testing I know have stable Android 7.1 Hyper-V and Android
8.1 with some mouse trouble. The Android 8.1 are in a RC version so hopefully there
will be a new version fixing this soon. If you need to test out 8, it works
with keyboard input.I did try the same steps on an Android 6, but that one failed to start after a successful install. So, if you need to use version 6 or older of Android you should chose Virtual Box/VmWare or try to figure out a solution (and tell me).
So just so that I shall remember all this myself I have
created this quick guide on how to get it running, and if anybody else finds it
helpful it’s a double score 😉
Check out the Android-X86 project to get the latest version of
necessary iso file: http://www.android-x86.org/
The files that works on Hyper-V seams to have the filename pattern
of “_64” after “Android-x86” and followed by the version. Example: “android-x86_64-7.1-r2.iso”
This might change or be different if you get you files from
another location. Something that will happen if you use the wrong version are
that the process will stop right after you have selected “Yes” on the “Do you
want to install boot loader GRUB?”. You will see that the cursor appear on a
single blank line and you can type inn stuff. This means that the process has
stopped, NO POINT IN WAITING!
CREATING THE VIRTUAL
MACHINE
So now we have the correct iso file, lets start to create the
VM. Create a new “Virtual Machine…” in Hyper-V manager, make sure it’s generation
1
If
you try to use dynamic memory you will run into trouble, so be sure to turn
that one off. Try out how much you need to
assign, 2 GB should be enough in most cases
Typical messages that can appear if you have dynamic memory
enable are stuff like this
And that is if you are lucky and not everything crashes.
When it comes to network you have to edit it after going
through the wizard, Android can currently not use the default network adapter. I
will show how you change it to “Legacy Network Adapter” later. Using the
“Default Switch” are no problem, but you can also create a separate switch if
desired.
Create a new virtual hard disk, don’t make it to big. Expandable
disk works fine
Mount the iso files
Check the summary and you are now almost ready.
Remember that you need to add a legacy network adapter, and
adding extra CPU can also be a good idea.
Open settings for the newly created VM and add the card
Remove the old one and set the right virtual switch. Add
virtual processors if desired, 2 is always nice
INSTALLING ANDROID
Connect to the VM and start it
On the “Choose Partition” select “Create/Modify partitions”
and click “OK”
Select “New”
Follow the wizard, just click enter to contain the default
values, typing a name for the partition can make it easier to find it later.
Select the newly created partition and select “Write”, if
you don’t do this it will not be created. You must type in “Yes” to verify that
you want to create it.
Selecting “Exit” will take you back and the partitions
should now be available. With partition selected click “Ok”
Select filesystem and click OK
Confirm that you will format the partition and “GRUB” boot
loader with “Yes” (have skipped some pictures)
NB!
This is the part mention earlier that installation will fail if you have the
wrong installation media. You will see that the cursor appear on a single blank
line and you can type inn stuff. This means that you must get the right iso
file and start over.
Before the installation starts you will get a questions if
the system directory should be read-write. Answer no if you don’t have any
reason for saying yes
When the installation are finished be sure to eject the
iso/cd from the VM and select “Run Android-x86” and click on “OK”
Go through the Android wizard and be sure to select
“Taskbar” as “Home app” and click “Always”
This will give the VM a tablet setup and make the keyboard
and mouse work. If you want to test out the different home app, just click on
“Just once” instead of always.
You should now have a working Hyper-V VM with Android
installed and be able to run Play Store.