Running Android Emulator and Docker simultaneously on Windows
As I set on learning React Native Journey I hit a road block when I was trying to run both Android Emulator and Docker simultaneously on Windows.
Although installation of Docker and Android is easy as such. It becomes a problem when one has to run both Docker and Android Emulator simultaneously. Docker uses Hyper V from Windows and Android Emulator uses Intel’s HAXM. Since both are incompatible one gets to use only one application.
To circumvent this Microsoft unveiled its own Android Emulator. Installation is smooth. But beyond that getting Android Studio to recognise it is a pain.
Here I will show you how to do that (Thanks to internet ofcourse :) )
Assuming you are going to do everything from scratch on a Windows 10 machine with Intel processors, here are the steps I followed —
a) Install Android Studio from the link
b) Enable Hyper-V and the Windows Hypervisor Platform on Windows
Open Turn Windows features on or off and select Hyper-V and the Windows Hypervisor Platform checkboxes.
For these features to take effect, you will need to restart your machine.
After Restart
c) Now Install Microsoft’s Android Emulator
d) Once you are done with Installation Launch an Emulator.
e) After this launch Android Studio and Run Your “Hello World” Application.
You should now see “Select Deployment Target” Dialog box. It should list the Emulator. Simple isn’t it :)
But I am guessing you will be stuck just as I was. So here comes the magic steps.
f) Run regedit.
g) Go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\
h) Check if you have “Android SDK Tools” key there. If not create one
i) Select Android Sdk Tools that you created in previous step and go to right hand window.
j) Create a String with Name “Path” and Value “<Path of Android SDK>”
For me Android SDK came with Android Studio so path was C:\Users\<user>\AppData\Local\Android\SDK
k) After this restart adb server by giving these commands
adb kill-server
adb start-server
l) Now run your favourite “Hello World” and you should be able to see the Emulator.
Footnote: Google has already announced support for Hyper V. But on Intel machines it still supports HAXM. But in future we can expect Android Emulators not needing any special hacks while other software like Docker needing Hyper V is installed and running on the machine.
Update on the Footnote (14.09.2018): I installed the latest Emulator for Android Pie (AVD Pie 9.0; API 28) and it worked without HAXM. while docker was running in background. So one should not need MS Emulator in future.
References:
https://blogs.msdn.microsoft.com/visualstudio/2018/05/08/hyper-v-android-emulator-support/