11

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Angelo Dias
  • 1,125
  • 4
  • 13
  • 23
  • Here is a working solution https://stackoverflow.com/questions/67912223/running-wsl2-and-android-studio-at-the-same-time-with-a-ryzen-processor – otocon Jul 13 '21 at 21:29
  • In rescent android studio, no need to setup _ANDROID_SDK_ROOT_ ``` lang-sh export ANDROID_HOME=/home/__/Android export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools ``` is fine. – agfe2 Apr 25 '22 at 03:00

2 Answers2

6

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

Angelo Dias
  • 1,125
  • 4
  • 13
  • 23
0

This question is already resolve in this topic, and the solution for this problem is very simple:

for example, my SDK PATH in windows is in this location:

/mnt/d/Android/Sdk/platform-tools/adb.exe

then in my wsl bash console I need to install adb:

sudo apt install adb

the default installation PATH in wsl is this:

/usr/bin/adb

now change the adb to adb_bk inside the wsl installation PATH:

sudo mv /usr/bin/adb /usr/bin/adb_bk

finally change the PATH inside your wsl installation for the windows PATH installation with the adb.exe:

sudo ln -s /mnt/d/Android/Sdk/platform-tools/adb.exe /usr/bin/adb

And when I run my ADB device in my windows this device is attached in my wsl adb:

adb devices

Guido T.
  • 51
  • 1
  • 6