Using the Android emulator on Windows 10 with WSL2

Adrien Pellegrini
2 min readFeb 22, 2020

Unfortunately it’s not that simple to run the Android emulator in Windows 10 and start, for example, a React-Native app from WSL2 inside this Android emulator.

The Android Device Manager installed with Visual Studio 2019.

The emulator you want to use in Windows need to be installed in WSL2 too with the exact same version.

Here after you will a few commands I used in WSL2 (Ubuntu) to set up my environment:

Some environment variables are required by Java and Android tools. This is the relevant part of my .zshrc file:

if [[ -e /usr/lib/jvm/java-8-openjdk-amd64 ]]; then
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export PATH="$PATH:$JAVA_HOME/bin"
# Android tools
if [[ -e $HOME/android-sdk-tools ]]; then
export PATH="$HOME/android-sdk-tools:$HOME/android-sdk-tools/bin:$PATH"
export PATH="$HOME/.android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/.android"
export ANDROID_SDK_ROOT="$HOME/.android"
export REPO_OS_OVERRIDE="linux"
adb kill-server 2> /dev/null
export ADB_SERVER_SOCKET=tcp:$(cat /etc/resolv.conf | grep nameserver | cut -d' ' -f2):5037

Those environment variables need to be added before using the sdk-manager tool from the first snippet.

Be aware also that the adb server must not be started in WSL2 since we want to use the emulator in Windows. So each time WSL2 starts, we need to kill the adb server of WSL2.

To use adb from windows, you can follow my other post here.