This Powershell script lets you map ports from your WSL2 instance to the same ports on your Windows host machine. It's useful when working with development tools that must comunicate between the host and the WSL2, such an Android emulator running on Windows and a development server running on WSL2.
- Start your WSL2 instance
- Write into the
$ports
array the ports you want to map. - With the WSL2 instance running, run the powersell script on Windows as administrator.
Unfortunately, as the WSL2 instance IP address is dynamic and changes everytime the instance is restarted, you must repeat the step 3. every time you relaunch WSL2.
From my "response" in Stack Overflow:
- Install an Android Emulator and use the Android Image that contains Google Services and all related Google Stuff.
- Login into your Google account on the emulator. Then, go to the Google Play Store (the apps store) on the emulator and download the Expo app.
- On the downloaded Expo app, login in with the same Expo account you uses for development.
- You should be able to see the development app on Recently in development or Recently opened. If not, just open it scanning the QR from your Android Phone (not the emulator) once, to be shyncronized with your expo account.
5 Also, you could copy the url
exp://<your-windows-ip>:90000
and it should be detected in the emulator from clipboard.