How can I run both Docker and Android Studio Emulator on Windows?

WindowsAndroid StudioDockerHyper V

Windows Problem Overview


Android Emulator is incompatible with Hyper-V, but Docker relies on Hyper-V. Is there any solution that I can run them simultaneously?

Windows Solutions


Solution 1 - Windows

Android emulators can now run on Hyper-V. From @tmanolatos answer, here are the steps:

  1. In start menu search for Turn Windows Features on or off

  2. Check the box Windows Hypervisor platform:

    turn windows features on or off - windows hypervisor platform

  3. You may be required to sign out of your system and sign back in

  4. Docker and Android Studio Emulators should work together with no issue

For more details refer to Configure VM acceleration on Windows.

Solution 2 - Windows

I was in the same situation and I think I came to a solution just a minute ago. The trick is to rely on VirtualBox to host the Docker engine. And the good news is that you can setup this using only docker commands !

Create virtualbox Docker machine

The command below will create a virtualbox machine that will run the actual Docker environment. It will download an image and setup everything for you.

> docker-machine create --driver virtualbox default

Once it has finished, you can check if the machine has been successfully created using the docker-machine ls command.

> docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v17.04.0-ce

Setup shell

The machine has been created but the shell still need to be configured to access this remote Docker instance. The environment variables to set can be obtained using the docker-machine env default command. The output will be automatically adapted to the shell you are using (Powershell in the example below).

> docker-machine env
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.99.100:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\DummyUser\.docker\machine\machines\default"
$Env:DOCKER_MACHINE_NAME = "default"
$Env:COMPOSE_CONVERT_WINDOWS_PATHS = "true"
# Run this command to configure your shell:
# & "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env | Invoke-Expression

Note that the last few lines returned by this command will tell you how to automatically apply the environment variables with a single command. You still can simply copy/paste the commands in your terminal.

Run docker !

That's it ! Now, you can run a simple docker command to make sure everything runs smoothly !

> docker run busybox echo hello world
 Unable to find image 'busybox' locally
 Pulling repository busybox
 e72ac664f4f0: Download complete
 511136ea3c5a: Download complete
 df7546f9f060: Download complete
 e433a6c5b276: Download complete
 hello world

Source: https://docs.docker.com/machine/get-started/

Solution 3 - Windows

If you want to keep running Hyper-V, an alternative to the standard Android emulator is Microsoft's [Visual Studio Emulator for Android][1], which is compatible with Hyper-V.

The Microsoft's emulator will appear as a connected Android device.

[![enter image description here][2]][2]

[This article][3] provides more details.

[1]: https://www.visualstudio.com/vs/msft-android-emulator/ "Visual Studio Emulator for Android" [2]: https://i.stack.imgur.com/c8Blv.png [3]: http://www.itwriting.com/blog/9371-how-to-run-android-studio-on-windows-without-disabling-hyper-v.html

Solution 4 - Windows

It seems that Google have just offered a new version of Emulator that is compatible with Hyper-V. Check https://android-developers.googleblog.com/2018/07/android-emulator-amd-processor-hyper-v.html - so you can finally have both native Windows Docker (through HyperV) and Android Emulator running...

Mind the gap, though:

> Again, for existing Windows users who have an Intel-based processor, the Android Emulator will continue to use the faster and recommended Intel HAXM configuration. For those using AMD processors, and those who use Hyper-V hypervisors, this should be an exciting step forward to start using the Android Emulator.

Solution 5 - Windows

While I wish it weren't the case, you can't use the Microsoft emulator anymore if you want to target devices running anything newer than Marshmallow.

HolySamosa's answer is unfortunately not feasible now because Microsoft is no longer adding new versions of Android to their emulator as explained here.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLovelyJuiceView Question on Stackoverflow
Solution 1 - WindowsuruemuView Answer on Stackoverflow
Solution 2 - WindowsSylfoView Answer on Stackoverflow
Solution 3 - WindowsHolySamosaView Answer on Stackoverflow
Solution 4 - WindowstmanolatosView Answer on Stackoverflow
Solution 5 - WindowsPranavView Answer on Stackoverflow