If you're like me, and use WSL to keep all your dev stuff neatly separated from Windows, you might have faced some challenges setting up Android development.
While I was developing some Capacitor apps that required native Android code changes, I first tried to install Android Studio on Windows and link the dependencies to WSL. But that was really fragile and just didn't work. Then I found out that I could run Android Studio directly on WSL, which was way better.
But now how do I connect my Android device to WSL? Running an emulator works, but dude, a WSL instance, Android Studio, AND an emulator? 32 GB of RAM was reaching its limits with browser tabs open. Plus you'll also likely need a browser open inside WSL itself to use DevTools on the WebView of the app.
So after lots of trial and error, here's how I got it working:
Prerequisites
Before diving in, you'll need one of the following:
- A physical Android device with USB debugging and WiFi debugging enabled (faster and less resource-intensive)
Installing Android Studio on WSL
First, we need to get Android Studio installed directly in WSL:
- Visit the Android Studio download page
- Copy the download link for the Linux
.tar.gzpackage - Open your WSL terminal and download it:
wget "https://redirector.gvt1.com/edgedl/android/studio/ide-zips/.../android-studio-...-linux.tar.gz" - Follow the official Linux installation guide to extract and set up Android Studio
- Launch Android Studio and complete the setup wizard
The wizard will guide you through installing the necessary SDK tools and components.
Deploying to a Physical Device
This is where things get interesting. Since WSL doesn't have direct access to USB devices, we need to route the connection through Windows.
Installing ADB on Windows
- Download platform-tools for Windows
- Extract the ZIP file to a location like
C:\platform-tools - Add this directory to your Windows PATH environment variable (optional but convenient)
Connecting via WiFi Debugging
Here's the trick to connect your phone to WSL wirelessly:
-
Enable Developer Options and WiFi Debugging on your Android device
-
Open PowerShell on Windows and start the ADB server:
adb start-server -
Connect your phone via USB initially (to Windows) and enable TCP/IP mode:
adb tcpip 5555Your phone should show a debugging authorization prompt - accept it.
-
Disconnect the USB cable and get your phone's IP address from WiFi settings (usually found in Settings → WiFi → Current Network)
-
Now, in your WSL terminal, connect to the device:
adb connect <your-phone-ip>:5555 -
Verify the connection:
adb devicesYou should see something like:
List of devices attached 192.168.0.15:5555 device
Port Forwarding
Once connected, you need to forward ports so your phone can access services running on WSL:
# Forward port 5173 (or whatever port your dev server uses)
adb reverse tcp:5173 tcp:5173
This makes localhost:5173 on your phone point to localhost:5173 on WSL. Pretty neat!
No need for weird Android emulator IP tricks.
Tips and Troubleshooting
Connection Issues
If adb devices shows "unauthorized":
- Check your phone for a debugging authorization prompt
- Try revoking USB debugging authorizations in Developer Options and reconnecting
If the WiFi connection keeps dropping:
- Make sure your phone doesn't have aggressive battery optimization for the Android Debug Bridge
- Keep both devices on the same WiFi network
- Try reconnecting:
adb disconnect <ip>thenadb connect <ip>:5555
Performance
- Using a physical device is much lighter on RAM than running an emulator
- The WiFi connection is surprisingly stable and fast enough for development
- You can keep the connection across WSL restarts
Dev Server Access
For web-based apps (like Capacitor or Ionic):
- Use
adb reversefor physical devices - Make sure your dev server allows external connections (check firewall settings and
vite --host)
Conclusion
While setting up Android development on WSL requires a bit more setup than native Windows or Linux, it's totally doable and works really well once configured. The WiFi debugging approach is particularly nice because you can develop without being tethered to a USB cable.
The key takeaways:
- Install Android Studio directly in WSL for better integration
- Use ADB on Windows to establish the initial connection
- Connect via WiFi debugging for wireless development
- Use
adb reversefor port forwarding
Happy Android developing on WSL! 🚀


































































































































