How to Connect an Android Emulator to WSL

Connecting an Android Emulator or a real Android device to WSL (Windows Subsystem for Linux) can be very useful for development purposes. This tutorial will guide you through the steps required to establish this connection over USB.

Step 1: Configure ADB on the Host OS

First, you need to configure the Android Debug Bridge (ADB) on your host operating system where the Android Emulator or the real device is connected via USB.

  1. Kill any existing ADB server instances:

    Open a terminal and run the following command:

     adb kill-server
    
  2. Start the ADB server in no-daemon mode:

    Run the following command to start the ADB server in no-daemon mode:

     adb -a server nodaemon
    

Step 2: Configure ADB on WSL

Next, you need to set up the ADB connection on WSL.

  1. Export the ADB server socket:

    On your WSL terminal, export the ADB server socket with the IP address of your host machine. Replace [IP_HOST] with the actual IP address of your host:

     export ADB_SERVER_SOCKET=tcp:[IP_HOST]:5037
    

  2. Check connected devices:

    Finally, verify the connection by listing the connected devices:

     adb devices
    

    You should see your Android Emulator or real device listed.

Conclusion

Following these steps will allow you to connect your Android Emulator or real device to WSL via USB, enabling you to use ADB commands from within WSL. This setup can streamline your development process by integrating the capabilities of WSL with Android development tools.

0
Subscribe to my newsletter

Read articles from Muhammad Mushlih directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Muhammad Mushlih
Muhammad Mushlih