Manually installing the Flutter development environment on MacOS.

The official documentation for installing the Flutter development environment is very clear. However, it requires the installation of the large Android Studio software. I prefer to use the lightweight VSCode tool for development, so I have compiled a guide on how to install and configure the Flutter development environment without installing Android Studio.

Prepare java envrioment

Download jdk from https://adoptium.net/temurin/archive/ . unzip to ~/apps/jdk dir.

Set Java env

1JAVA_HOME=~/apps/jdk/Contents/Home
2PATH=$JAVA_HOME/bin:$PATH:.
3CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
4
5PATH=~/apps/flutter/bin:$PATH
6
7export JAVA_HOME
8export PATH
9export CLASSPATH

Download flutter sdk

1cd apps
2git clone git@github.com:flutter/flutter.git

Download Command line tools from android developer site https://developer.android.com/studio#command-tools . unzip and cd to cmdline-tools/bin

1mkdir ~/apps/android-sdk
2./sdkmanager --sdk_root=/Uers/youname/apps/android-sdk "cmdline-tools;latest"

Create android home directory

1mkdir ~/apps/android-home

Config .zshrc (if you use bash then Config .bashrc file)

 1ANDROID_SDK_ROOT=~/apps/android-sdk
 2CMDLINE_TOOLS_HOME=$ANDROID_SDK_ROOT/cmdline-tools/latest
 3FLUTTER_HOME=~/apps/flutter
 4PATH=$CMDLINE_TOOLS_HOME/bin:$PATH
 5PATH=$FLUTTER_HOME/bin:$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/platform-tools:$PATH
 6
 7ANDROID_SDK_HOME=~/apps/android-home
 8export ANDROID_SDK_HOME
 9
10export PATH
1flutter channel stable

Install SDK Package

1# install emulator
2sdkmanager --install "emulator"
3
4# install platform-tools
5sdkmanager --install "platform-tools"

Check install

 1➜  ~ sdkmanager --version
 29.0
 3
 4➜  ~ emulator -version
 5INFO    | Android emulator version 32.1.13.0 (build_id 10086546) (CL:N/A)
 6...
 7
 8➜  ~ adb version
 9Android Debug Bridge version 1.0.41
10Version 34.0.3-10161052
11Installed as ...
12
13➜  ~ fastboot --version
14fastboot version 34.0.3-10161052
15Installed as ...

SDK install and update

1➜  ~ sdkmanager --list
2[=======================================] 100% Computing updates...
3Installed packages:
4  Path                 | Version | Description                             | Location
5  -------              | ------- | -------                                 | -------
6  cmdline-tools;latest | 9.0     | Android SDK Command-line Tools (latest) | cmdline-tools/latest
7  emulator             | 32.1.13 | Android Emulator                        | emulator
8  patcher;v4           | 1       | SDK Patch Applier v4                    | patcher/v4
9  platform-tools       | 34.0.3  | Android SDK Platform-Tools              | platform-tools

Other Command

1sdkmanager --update
2sdkmanager --uninstall

Install build-tools

1sdkmanager --install "build-tools;31.0.0" "platforms;android-31"

Install simulator images

1sdkmanager --install "system-images;android-31;default;x86_64"

Print device list

1avdmanager list device

Create simulator

1$ avdmanager create avd --name android-31-default --package "system-images;android-31;default;x86_64" --device "pixel_6_pro"
2Do you wish to create a custom hardware profile? [no]

You can write by short param: -n replace --name, -k replace --package, eg: avdmanager create avd -n android-31-default -k "system-images;android-31;default;x86_64"

Check simulator

1avdmanager list avd

Run simulator

1# Command help: 'emulator -avd $AVD_NAME' or '$ emulator @AVD_NAME'
2emulator -avd android-31-default

Install CocoaPods

1brew install cocoapods

Set flutter android sdk directory

1flutter config --android-sdk=~/apps/android-sdk

Accept android licenses

1flutter doctor --android-licenses

Check flutter envrioment

 1➜  ~ flutter doctor
 2Doctor summary (to see all details, run flutter doctor -v):
 3[] Flutter (Channel stable, 3.10.3, on macOS 12.5 21G72 darwin-x64, locale en-US)
 4[] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
 5[] Xcode - develop for iOS and macOS (Xcode 14.2)
 6[] Chrome - develop for the web
 7[!] Android Studio (not installed)
 8[] IntelliJ IDEA Ultimate Edition (version 2022.3)
 9[] VS Code (version 1.78.2)
10[] Connected device (2 available)
11[] Network resources
12
13! Doctor found issues in 1 category.