Install Flutter Without Android Studio on Ubuntu

 

Install OpenJDK 8

I am using java 8 because the latest version of java creates some problem with flutter so version 8 is fine.

In terminal type:

sudo apt install openjdk-8-jresudo apt install openjdk-8-jdk

Install Git

In terminal type:

sudo apt install git

Setting Up Folder

I am keeping everything in a single directory. Using terminal or you can make a folder by own inside “Home” directory.

cd ~
mkdir Android
cd Android
mkdir cmdline-tools

Install Flutter SDK

Download flutter from the following URL

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

tar xvf flutter_linux_1.17.3-stable.tar.xz

Now move the “flutter” folder to “Home/Android/” directory

sudo mv flutter/ ~/Android/

Now the full path looks like this

Home/Android/flutter

Install Android Command Line Tools

Install android command line tools for Linux from the following URL

https://developer.android.com/studio#command-tools

Go to the folder where you downloaded this file and unzip the file.

unzip commandlinetools-linux-6609375_latest.zip

Now move the “tools” folder to “Home/Android/cmdline-tools/” directory

sudo mv tools/ ~/Android/cmdline-tools/

Now the full path looks like this

Home/Android/cmdline-tools/tools

Set Some Environment Variables

now go back to “Home” directory and open up the “.bashrc” file for setting up some environment variables

cd ~
sudo gedit .bashrc

Now write this at the end of the .bashrc file

export 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 ANDROID_SDK=$HOME/ANDROID
export PATH=$ANDROID_SDK:$PATH
# Flutter
export FLUTTER=$ANDROID/flutter
export PATH=$FLUTTER/bin:$PATH

save the file

Download Android SDK

So for flutter to run we need to install system-image, platform-tools, build-tools, platforms; android.

I am using android-29, you can use the version which is compatible with your Android device. If you want to see all available version for system-image, platform-tools, build-tools, platforms; android type following in the terminal

sdkmanager --list

for version 29 type following command in terminal

sdkmanager “system-images;android-29;default;x86_64”
sdkmanager "platforms;android-29"
sdkmanager “platform-tools”
sdkmanager "build-tools;29.0.3"

Now accept the licenses.

sdkmanager --licenses

Configure SDK path for flutter

flutter config --android-sdk ~/Android

Call To Flutter Doctor

Run this command in terminal

flutter doctor -v

This command give 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-licenses

Setup Your Android Phone

For running Flutter App on our physical device we need to turn on USB Debugging on your android phone. Its very simple to do just search on google “how to turn USB Debugging on ‘phone_name’” or use below link as a reference

Again Run Flutter Doctor

Run this command

flutter doctor -v

your phone show a popup

If you see error like following then Type following in the terminal

sudo apt-get install android-sdk-platform-tools-common

Then unplug your phone from pc then Turn OFF and then Turn ON usb debugging on your android device and reconnect to pc via usb .

Again run flutter doctor

flutter doctor -v

Test Flutter Code

Let’s create a flutter project

In terminal type:

cd Desktop/
flutter create hello_world
cd hello_world
flutter run

Popular posts from this blog

How To Flash China Tablets (Easy Method)

How To Create A Hidden Service On Tor Using Android With Termux

How To Create And Configure Sudo User On Arch Linux