Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Android emulator on windows while using WSL2 with zsh?

I'm based on this answer: https://stackoverflow.com/a/58229368/13495096

I need to develop using react-native in Windows through WSL2.

I did exactly what the answer says and after a few hours of solving some errors, got to the point where:

  • WSL2 is installed and running (Ubuntu 20.04 LTS)
  • Android Studio is installed on Windows 10 (Pro x64);
  • ADB is with the same version in both WSL2 and Windows (1.0.32);
  • $PATH is configured properly (below) in my .zshrc file:
# Android SDK

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
export ANDROID_HOME=/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$PATH

I start a device on Android Studio (Windows) and in Powershell, when running adb devices, it returns:

List of devices attached
emulator-5554   device

When I run adb devices on my WSL terminal, it returns only List of devices attached, with nothing else.

Based on the linked answer, it's possible to do it but I can't. How can I make that happen? What am I missing?

I'm moving from OS X to Windows and I never tried Linux.

like image 327
Angelo Dias Avatar asked Jun 15 '20 23:06

Angelo Dias


People also ask

Can Android emulator run on virtual machine?

Android Emulator allows you to run emulations of Android devices on Windows, macOS or Linux machines. The Android Emulator runs the Android operating system in a virtual machine called an Android Virtual Device (AVD). The AVD contains the full Android software stack, and it runs as if it were on a physical device.

How do I run an emulator from ADB?

Install your app using adb. Run and test your app on the emulator. While the emulator is running, you can also use the Emulator Console to issue commands as needed. The virtual device preserves the app and its state data across restarts, in a user-data disk partition ( userdata-qemu.

Can Linux run Android emulator?

Anbox, a free-of-cost and open-source and one of the best Android emulator for Linux would let any kind of Android mobile app and games run smoothly on the Linux distro. This platform also allows you to run Android apps in the cloud. Anbox goes on to run Android apps in tight box containers.


1 Answers

Ended up finding this tutorial that solved my problem (but raised some others, like not being able to access localhost from Android Emulator)

https://gist.github.com/bergmannjg/461958db03c6ae41a66d264ae6504ade

like image 164
Angelo Dias Avatar answered Oct 22 '22 12:10

Angelo Dias