Install Flutter in Linux without Android Studio
Here I will show you how we can set up Flutter in Linux without installing Android Studio. This is very useful if your PC runs slow or don’t like the android studio and you want to code in some other editor.
Reminder: Guys, This all process is tested in arch based distros. Please install the packages accordingly with your package installer.
Use the terminal for this tutorial.
I am using java 17. You can use other version too.
Install Java
sudo pacman -S openjdk-17-jdkInstall Git
sudo pacman -S gitSetting Up Folder
I am keeping everything in a single directory. Use a terminal or you can make a folder inside the “home” directory.
cd ~/
mkdir Android && cd Android
mkdir cmdline-toolsInstall Flutter SDK
Download Flutter
Go to the folder where you downloaded the zip file and unzip the file. You can unzip it by right click on the file and click on extract here or using the terminal by the following code.
unzip flutter_linux_3.3.10-stable.tar.xzNow move the flutter folder to the ~/Android/ directory
sudo mv flutter/ ~/Android/Now the full path looks like this
~/Android/flutterInstall Android Command Line Tools
Download Android command-line tools for Linux
Got to the folder where you downloaded the file and unzip the file.
sudo tar -xvf commandlinetools-linux-11076708_latest.zipNow move the tools folder to the ~/Android/cmdline-tools directory
sudo mv tools/ ~/Android/cmdline-tools/Now the full path looks like this
~/Android/cmdline-tools/tools
Set Some ENV Variables
cd ~
sudo nano .zshrcexport ANDROID=$HOME/Android
export PATH=$ANDROID/cmdline-tools/tools:$PATH
export PATH=$ANDROID/cmdline-tools/tools/bin:$PATH
export PATH=$ANDROID/platform-tools:$PATH # Android SDK
export PATH=$ANDROID/emulator:$PATH
export ANDROID_SDK=$HOME/ANDROID
export PATH=$ANDROID_SDK:$PATH # Flutter
export FLUTTER=$ANDROID/flutter
export PATH=$FLUTTER/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
exportDownload Android SDK
So for Flutter to run we need to install system-image, platform-tools,builde-tools,platforms:android,cmdline-tools;latest.
I am using android-31, you can use the version which is compatible with your Android device. If you want to see all available versionsfor system-image, platform-tools, build-tools, and platforms; android type the following in the terminal.
sdkmanager --listfor version 31 type the following command in terminal
sdkmanager “system-images;android-31;default;x86_64”
sdkmanager "platforms;android-31"
sdkmanager “platform-tools”
sdkmanager "build-tools;31.0.0"Now accept the licenses.
sdkmanager --licensesInstall Android Emulator
sdkmanager "emulator"Setup Android Emulator
sdkmanager "system-images;android-31;default;x86_64"
avdmanager create avd -n pixel -k "system-images;android-31;default;x86_64" --device "pixel"In my case the .android folder is located in ~/.config to make flutter recognize it.
ln -sf ~/.config/android/ ~/Configure SDK path for Flutter
flutter config --android-sdk ~/AndroidCall flutter doctor
flutter doctor -vThis command gives you all green tick, ignore [!] at android studio because we are not using it.
if it ask for Accept Licenses with flutter doctor use below command to accept licenses
flutter doctor --android-licensesyour phone show a popup click on allow
If you don’t want to use your phone then do following.
emulator -avd pixelTest flutter code
cd Desktop/
flutter create hello_world
cd hello_world
flutter runHappy Coding!