I haven\'t done Android development in a while, so my knowledge of modern Android development is spotty.
I\'m trying to learn React Native. I use WSL as my primary d
For those who struggle to make Windows 10 Android Studio work with WSL2 located react-native project.
You need to install on your Windows 10 Android Studio.
Set user variable:
ANDROID_HOME=C:\Users\
Add to system variable PATH:
%ANDROID_HOME%\emulator
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_HOME%\cmdline-tools\latest (I'm not sure if this one is necessary)
Then go to your WSL2 and install:
sudo apt-get install unzipsudo apt-get install openjdk-8-jdkexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
export PATH=$PATH:$JAVA_HOME/bin
export ADB_SERVER_SOCKET=tcp::5037 (check your WSL adapter IP by running `ipconfig` in powershell.)
export ANDROID_HOME=$HOME/Android
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
sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"adb version && adb.exe version check if versions matchadb kill-server (ps) / adb.exe kill-server (wsl2 bash)adb -a -P 5037 nodaemon server (ps) / adb.exe -a -P 5037 nodeamon server (wsl2 bash) - don't close terminal window!emulator -avd (ps) / emulator.exe -avd - don't close terminal window!adb kill-server (WSL2 bash)adb devices (WSL2 bash) - you should now see your emulated device pick up it's id react-native run-android --deviceId=Same flow stays for USB connected devices. The only thing that is changing is that instead of step 4 you connect your developer enabled phone to PC and you should get in a terminal window with running adb server log that new device is connected.
NOTE:
You can run all commands in PowerShell by aliases without .exe and path only if you have defined environmental variables on windows 10 and extended PATH system variable. If you want to use
all commands from WSL2 bash you always need to add .exe when you want to execute something on windows side so WSL2 knows that it needs to
reach to windows executables.