Skip to content

Instantly share code, notes, and snippets.

@tcd93
Last active September 8, 2023 09:38
Show Gist options
  • Save tcd93/776679c3f12c835b5fcd74514896a381 to your computer and use it in GitHub Desktop.
Save tcd93/776679c3f12c835b5fcd74514896a381 to your computer and use it in GitHub Desktop.
Guide to run Flutter inside Window's WSL2 (Ubuntu 11)

Works with Flutter 3.13 on Windows 11 (with Ubuntu 22.04 on WSL2)

  1. Install Ubuntu 22.02 on Microsoft Store
  2. Login Ubuntu
  3. Install Android-sdk
    sudo apt-get update
    sudo apt-get install android-sdk
    export ANDROID_HOME=/usr/lib/android-sdk
  4. Get Java 18 (for some reason cmdline tools don't work with default jre versions that comes pre-packaged in Android-sdk)
    sudo apt install -y openjdk-18-jdk
  5. Install cmdline tools without Android Studio, go here to get latest download link
    wget https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip
    unzip commandlinetools-linux-10406996_latest.zip
    
    sudo chmod -R 777 /usr/lib/android-sdk
    sudo mkdir --parents "$ANDROID_HOME/cmdline-tools/latest"
    sudo mv cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest"
    export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$PATH
  6. Upgrade build-tools and android sdk version
    sdkmanager --install "build-tools;28.0.3"
    sdkmanager --install "platforms;android-29"
    
  7. Uninstall debug app if its already on device
  8. Follow these steps to allow USB connection into WSL2. Important: If you have Android SDK installed on host machine, make sure ADB is not running, execute adb kill-server before hand
  9. Plug in Android mobile device
  10. Check if ADB / Flutter recognizes (might encouter some authorization issues, just plug out and plug in again, change USB mode to Charge only)
adb devices
flutter devices
  1. Build and run project
flutter clean
flutter run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment