How to run Flutter SDK on windows without Android Studio
Guys I use Mac but it will help fellows who use Windows PCs. This a great journey for anyone there who wants to become a flutter developer
Start by opening the Command prompt (cmd) <windows-key> + R
then type cmd
Create the working Dir
It's better to keep everything in one directory considerC:\Android
as main working directory
cd C:\
mkdir Android
cd Android
Installing OpenJDK 8
Download Windows binaries from the following URL:
https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_windows_hotspot_8u202b08.zip
Other releases:
https://github.com/AdoptOpenJDK/openjdk8-binaries/releases
Extract it and rename the internal folder “jdk8u202-b08” to “OpenJDK” and copy it under “C:\Android” folder, the path will look like below:
C:\Android\openjdk
Installing Flutter SDK
Download flutter SDK latest version from the following URL:
https://flutter.io/docs/get-started/install/windows
Extract it, look for the folder with the name “flutter” to C:\Android folder, so the full path will be:
C:\Android\flutter
Installing Android command tools
Download Windows version of Android command tools from the following URL:
https://developer.android.com/studio/#command-tools
extract it and rename the “tools” folder to “SDK”, then copy it under C:\Android folder, the path will look like below:
C:\Android\sdk
Set Some Environment variables
We need to define some environment variable which let the above tools know how to contact each other, form command prompt run these commands, one by one:
setx JAVA_HOME “C:\Android\openjdk”
setx ANDROID_HOME “C:\Android”
setx ANDROID_SDK_ROOT “C:\Android\sdk”
setx path “%path%;”C:\Android\sdk;C:\Android\sdk\bin;C:\Android\flutter\bin”
Download Android SDK
As you may already know the Flutter are based on Android SDK to work, so we need to download system images, platform tools, build tools, platforms, and emulator, by running the following commands:
sdkmanager “system-images;android-27;default;x86_64”
sdkmanager “platform-tools”
sdkmanager “build-tools;27.0.3”
sdkmanager “platforms;android-27”
sdkmanager emulator
Note1: the date I write this tutorials the latest version of the above images was 28, but I downloaded the previous one, so I can develop app for wider range of Android OS versions, you can run the command
sdkmanager --list
to see available images and choose whatever you want.Note2: Make sure to accept any license that appear by pressing
y
thenEnter
, or nothing will be downloaded.
Accept the licenses
Android SDK images have licenses that need to be accepted, you do that with the command:
sdkmanager — -licenses
just press y
then Enter
for for every license.
Configure Flutter
configure flutter to know the dir of the Android SDK path
flutter config — -android-sdk C:\Android\
Create the Emulator
Create a new emulator with the name “nexus” or choose the name you want:
avdmanager -s create avd -n nexus -k “system-images;android-27;default;x86_64”
answer with [no] to the showed question.
Run the emulator
flutter emulators --launch nexus
Moment of truth
flutter doctor -v
This command should give all green and ok, ignore the Android Studio complain, since this lesson is all about ignoring it in the first place.
Test flutter code
cd C:\Android\flutter\examples\hello_world
flutter run
[Extra] Other Good Emulator commands
Run emulator using emulator
command, it should be executed from inside C:\Android\emulator
cd C:\Android\emulator
emulator -avd nexus
This command is good to see error messages
Create an emulator based on real device features
avdmanager -s create avd -n latest -k “system-images;android-27;default;x86_64” -d 30
you need to change the 30 with any other device id, you can see all available devices with the command:
avdmanager list device
Delete existed virtual emulator
avdmanager delete avd -n nexus
List all already created virtual emulators
avdmanager list avd
for more help
avdmanager help