Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save velia-vito/bd8e8c3458f6917116d3352b7f020510 to your computer and use it in GitHub Desktop.
Save velia-vito/bd8e8c3458f6917116d3352b7f020510 to your computer and use it in GitHub Desktop.
How to setup flutter with the Android SDK, WSL-Ubuntu, and Windows dev toolchains but, without Android Studio and other Space consuming junk --- a.k.a, a lean install

Tested/Updated on: 27 May 2023 (02.12 AM)

Flutter Setup

Create a working directory

Create a folder to Store all Flutter related stuff. We will refer to this folder as FlutterFolder here on out.

mkdir Flutter
cd Flutter

Install Flutter

Download and extract the latest version of flutter from their releases page (windows), or clone the stable branch with git FlutterFolder:

git clone https://github.com/flutter/flutter.git -b stable

Setup Environment Variables

Add FlutterFolder\bin to PATH




Android Setup

Create a Working Directory

Create a folder to Store all Android related stuff. We will refer to this folder as AndroidFolder here on out.

mkdir Android
cd Android

Install JDK

You can use any version JDK but make sure you check the licensing first

JAVA 17 is prefered.

Install Android Command Line Tools

Download and extract Android Command Line Tools to AndroidFolder, create a new folder latest and move the folder contents into it. You should now have a folder structure as follows:

tree
└───cmdline-tools
    └───latest
        ├───bin
        └───lib

Setup some Environment Variables

  • Create and set JAVA_HOME to your JAVA install folder (if you installed JAVA into say D:\JDK17 add D:\JDK17 and not D:\JDK17\bin)

  • Create and set ANDROID_SDK_ROOT to AndroidFolder

  • Add AndroidFolder\cmdline-tools\latest\bin, AndroidFolder\emulator, AndroidFolder\platform-tools to the Path (don't worry, these folders will be created later on)

Install the SDK

READ NOTES BELOW FIRST

sdkmanager --install "platform-tools" "build-tools;33.0.2" "emulator" "system-images;android-29;google_apis_playstore;x86_64" "platforms;android-29"
  • sdkmanager can be found in AndroidFolder\cmdline-tools\latest\bin

  • Always get the latest version of build-tools (list of all packages can be found by running sdkmanager --list

  • I have installed Android-29 (Android Q), you can decide which version to install based on the cumulative usage as given on APILevels .

  • The system image you install should be of the same API level as your android platform, have google_apis if you want to use google APIs in your app or google_apis_playstore if you need google APIs and access to playstore/playstore-apps. x86 is for 32-bit operating systems, x86_64 is for 64-bit operating systems.

Check and install a hypervisor if necessary

emulator -accel-check

If the output shows "installed and usable" your good to go. Else, install/re-install the Hypervisor with

sdkmanager --install "extras;google;Android_Emulator_Hypervisor_Driver"

Also install the required

  • AMD GVM: Download, extract and run silent_install.bat from github (GVM).

  • Intel HAXM: Download, extract and run silent_install.bat from github (HAXM).

Accept all licenses

sdkmanager --licenses

Hit y and Enter for every license.




Windows Setup

Download and install Visual Studio Build Tools (ideal)/Visual Studio Community Edition with the Desktop development with C++ workload, the following components must be included:

  • MSVC C++ x64/x86 build tools

  • C++ CMake tools for Windows

  • Windows 10 SDK

  • ATL Build tools (for flutter firebase)




WSL-Linux Setup

Installing WSL

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
wsl --update

Hyper-V (that is required for WSL2) is an Enterprise Edition feature, so, if your edition of Windows doesn't come with Hyper-V, you can enable it by running the following bat script:

pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause

Installing Ubuntu

If you don't mind Ubuntu and it's virtual drive (which will only get bigger all the time) getting installed in some obscure corner of your disk,

wsl --list -o
wsl --install -d [distribution name]

If you care about where it is installed:

  • Make a directory to install Your Linux Distribution (we shall call this LinuxFolder)

  • Download the relevant .appx/.appxbundle file from this microsoft docs list and put it into your LinuxFolder.

  • Rename your downloaded file to .zip, then extract it and run the .exe that you find.

Create a working directory

Create a folder to Store all Flutter related stuff. We will refer to this folder as LinuxFlutterFolder here on out.

cd ~
mkdir Flutter
cd Flutter

For some reason WSL boots into Windows' C:\ drive insted of your linux distributions user-root folder. That is why you absolutey must mot miss the first cd ~ command — you'll end up installing all of this on windows instead of linux without that initial command.

You can make it easier to follow/understand the folder structure by physically looking at it by running explorer.exe . after entering the user-root folder (which is denoted as ~ on lixux.)

Install Flutter

Download and extract the latest version of flutter from their releases page (linux), or alternatively run the following in your LinuxFlutterFolder:

git clone https://github.com/flutter/flutter.git -b stable

You could also copy your windows Flutter files (make sure to copy the .git folder too), drop the least 3-5 commits and then run git pull to save data.

Install Flutter dependencies

sudo apt-get update
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev unzip

Setup Environment Variables

Add FlutterFolder\bin to PATH by adding PATH=~/Flutter/bin:$PATH to .bashrc (it is imperateve that the linux path be prepended else the windows installation of FLutter will take precedence.)

How to edit .bashrc:

cd ~
code .bashrc




Moment of truth

Run the following on both Windows AND Linux:

flutter doctor --verbose

This command should give all green and ok, ignore the Android Studio complaint, since this gist is all about ignoring it in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment