This content originally appeared on DEV Community and was authored by Abdullah Yasir
If you love using WSL2 for development but also need Android Studio on Windows — this guide is for you.
This setup runs Flutter (via FVM) natively inside WSL2, while all Android tools (SDK, Studio, emulators) stay on Windows.
After a lot of trial and error, I documented this configuration that works perfectly — Flutter builds, devices connect, and Gradle behaves nicely.
Overview
We’ll be combining the best of both worlds:
- WSL2 (Ubuntu) → Flutter, FVM, Java, Gradle
- Windows → Android Studio, Android SDK, emulators
- Wrapper scripts → To bridge WSL2 and Windows SDK tools seamlessly
Environment Configuration (~/.bashrc)
Android SDK (on Windows)
Your Android SDK lives here:
/mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk
Set the following environment variables:
-
ANDROID_HOMEandANDROID_SDK_ROOT→ point to that SDK path - Add Android tools (
cmdline-tools,emulator) to your PATH
Java (WSL2 native — recommended)
We’ll use OpenJDK 17 installed inside WSL2:
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
Add its bin folder to your PATH.
Flutter (via FVM)
Add your FVM-managed Flutter to PATH and set the Dart PUB_CACHE:
~/fvm/default/bin
Wrapper Scripts (~/bin/)
Since WSL2 can’t directly execute .exe files from Linux PATH, we’ll create small bash wrapper scripts to call the Windows versions transparently.
~/bin/adb → wraps adb.exe
~/bin/aapt → wraps aapt.exe
~/bin/aapt2 → wraps aapt2.exe
~/bin/zipalign → wraps zipalign.exe
Java wrappers are not needed — we’re using native WSL2 Java.
Android SDK Build Tools
We’ll make Windows executables appear Linux-friendly.
Go to:
/mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/build-tools/36.1.0/
Then copy and symlink the essential build tools as shown below.
Flutter Configuration
Tell Flutter to use WSL2’s Java:
flutter config --jdk-dir "/usr/lib/jvm/java-17-openjdk-amd64"
Project files will still reference the Windows SDK path (which is fine).
Step-by-Step Setup Guide
Step 1 — Install Prerequisites
sudo apt update
sudo apt install -y openjdk-17-jdk openjdk-17-jre
java -version
Step 2 — Install FVM and Flutter
Install FVM (see docs):
fvm install stable
fvm global stable
Step 3 — Configure ~/.bashrc
Append the following block:
# --- Android SDK + Flutter Development (WSL2 with Windows Android Studio)
# User bin (for wrappers like adb)
export PATH="$HOME/bin:$PATH"
# Android SDK (Windows)
export ANDROID_HOME=/mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
# WSL2 native Java (OpenJDK 17)
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
# Add Android tools
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin"
export PATH="$PATH:$ANDROID_HOME/emulator"
# Flutter (FVM)
export PATH="$HOME/fvm/default/bin:$PATH"
export PUB_CACHE="$HOME/.pub-cache"
export PATH="$PATH:$PUB_CACHE/bin"
Step 4 — Create Wrapper Scripts
mkdir -p ~/bin
cat > ~/bin/adb << 'EOF'
#!/bin/bash
exec /mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/platform-tools/adb.exe "$@"
EOF
cat > ~/bin/aapt << 'EOF'
#!/bin/bash
exec /mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/build-tools/36.1.0/aapt.exe "$@"
EOF
cat > ~/bin/aapt2 << 'EOF'
#!/bin/bash
exec /mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/build-tools/36.1.0/aapt2.exe "$@"
EOF
cat > ~/bin/zipalign << 'EOF'
#!/bin/bash
exec /mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/build-tools/36.1.0/zipalign.exe "$@"
EOF
chmod +x ~/bin/adb ~/bin/aapt ~/bin/aapt2 ~/bin/zipalign
Step 5 — Copy Android Build Tools
cd /mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/build-tools/36.1.0/
cmd.exe /c "copy aapt.exe aapt"
cmd.exe /c "copy aapt2.exe aapt2"
cmd.exe /c "copy zipalign.exe zipalign"
cmd.exe /c "copy aidl.exe aidl"
Step 6 — Create ADB Symlink
ln -s ~/bin/adb /mnt/c/Users/<your_windows_username>/AppData/Local/Android/Sdk/platform-tools/adb
Step 7 — Configure Flutter
flutter config --jdk-dir "/usr/lib/jvm/java-17-openjdk-amd64"
Step 8 — Reload and Verify
source ~/.bashrc
flutter doctor -v
Project Configuration
android/local.properties
Make sure it uses Windows path format:
sdk.dir=C:\\Users\\<your_windows_username>\\AppData\\Local\\Android\\Sdk
Expected flutter doctor Output
| Component | Status | Notes |
|---|---|---|
| Flutter | ![]() |
Fully functional |
| Android toolchain | ![]() |
Minor warnings are fine |
| Chrome | ![]() |
Optional (for web) |
| Linux toolchain | ![]() |
Optional (for desktop) |
| Android Studio | ![]() |
“Not installed” — totally normal (it’s on Windows) |
| Connected devices | ![]() |
Works fine |
| Network resources | ![]() |
All good |
Architecture Overview
┌─────────────────────────────────────┐
│ WSL2 (Ubuntu) │
│ ┌───────────────────────────┐ │
│ │ Flutter (FVM) │ │
│ │ Java (OpenJDK 17) │ │
│ │ Gradle │ │
│ └───────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────┐ │
│ │ Wrappers (~/bin/) │ │
│ │ - adb, aapt, aapt2, etc │ │
│ └───────────────────────────┘ │
│ ↓ │
└────────────┼────────────────────────┘
↓
┌────────────┼────────────────────────┐
│ Windows Host │
│ ┌───────────────────────────┐ │
│ │ Android SDK │ │
│ │ Android Studio │ │
│ │ Emulators/Devices │ │
│ └───────────────────────────┘ │
└─────────────────────────────────────┘
Files Modified or Created
| File | Purpose |
|---|---|
~/.bashrc |
Environment config |
~/bin/adb, ~/bin/aapt, etc. |
Wrapper scripts |
android/local.properties |
Windows SDK path |
Troubleshooting
Problem: JAVA_HOME invalid
Solution:
java -version
flutter config --jdk-dir "/usr/lib/jvm/java-17-openjdk-amd64"
Problem: flutter command not found
Solution:
fvm list
source ~/.bashrc
Problem: ADB not finding devices
Solution:
adb kill-server && adb start-server
Problem: Gradle build fails
Solution:
flutter clean
rm -rf android/.gradle
Problem: Could not find or load main class GradleWrapperMain
Solution:
source ~/.bashrc
That’s it!
Your Flutter + WSL2 setup is now fully functional.
No more Gradle confusion or path issues — just smooth, native Flutter builds in WSL2 with Android Studio staying comfortably on Windows.
This content originally appeared on DEV Community and was authored by Abdullah Yasir

Java wrappers are not needed — we’re using native WSL2 Java.
