DEV Community

Jayesh Kale
Jayesh Kale

Posted on • Edited on

Setting up flutter without Android studio

Sometimes due the hardware constraints or some other reasons developer will prefer light weight solution rather than Big Bulky Android Studio. So heres a good news for you in this article we will configure visual studio code to work with flutter without android studio. We are using ubuntu 19.04 as operating system but you can choose choice of your linux distros. So lets get started....

Packages we required

  1. Android command line tools
  2. Flutter Binaries
  3. Gradle build
  4. OpenJDK 8

Installing Packages

We are installing it by following below steps respectively:

  1. Navigate to folder where you downloaded your binaries.
  2. Extract it and move it to relevant location.
  3. Set up path and refresh .profile file to access utilities.

Installing Packages

To set up path open profile type in terminal
$ gedit ~/.profile

Android tools

$ unzip sdk-tools-linux-4333796.zip
$ mkdir Android
$ mv tools/ Android/
$ sudo mv Android/ /usr/lib 
Enter fullscreen mode Exit fullscreen mode
#android home
export ANDROID_HOME=/usr/lib/Android
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH

#android sdk root
export ANDROID_SDK_ROOT=/usr/lib/Android
export PATH=$ANDROID_SDK_ROOT:$PATH
Enter fullscreen mode Exit fullscreen mode

Flutter

$ tar xvf flutter_linux_v1.9.1+hotfix.2-stable.tar.xz
$ sudo mv flutter/ /usr/lib
Enter fullscreen mode Exit fullscreen mode
#flutter
export FLUTTER_HOME=/usr/lib/flutter
export PATH=$FLUTTER_HOME/bin:$PATH
Enter fullscreen mode Exit fullscreen mode

Gradle

$ unzip gradle-5.6.2-bin.zip
$ mkdir gradle
$ mv gradle-5.6.2/ gradle/
$ sudo mv gradle/ /opt
Enter fullscreen mode Exit fullscreen mode
#gradle
export GRADLE_HOME=/opt/gradle/gradle-5.6.2
export PATH=$GRADLE_HOME/bin:$PATH
Enter fullscreen mode Exit fullscreen mode

OpenJDK 8

  • Open synaptic package manager if you don't have it install via
$ sudo apt install synaptic
Enter fullscreen mode Exit fullscreen mode
  • Type in OpenJDK 8 to search bar.
  • Select
    1. openjdk-8-jdk
    2. openjdk-8-jdk-headless
    3. openjdk-8-jre
    4. openjdk-8-jre-headless
  • Apply and wait for install. Don't worry it will set up environment variable for you automatically.

Our installation of packages is done use subsequent command to refresh .profile
$ . ~/.profile

Setting up Android environment

For setting Android environment you have to download following packages. I'm Downloading latest one as the date of publishing but you can download many system images to support wide array of devices using sdkmanager.

Note: If you're facing issue with sdkmanager as Warning: Could not create settings then open up terminal and type $sdkmanager --sdk_root=${ANDROID_HOME} tools this will upgrade binaries to latest and everything will works as expected.

$ sdkmanager "system-images;android-29;google_apis;x86_64"
$ sdkmanager "platforms;android-29"
$ sdkmanager "platform-tools"
$ sdkmanager "patcher;v4"
$ sdkmanager "emulator"
$ sdkmanager "build-tools;29.0.2"
Enter fullscreen mode Exit fullscreen mode

Accept all licenses using

sdkmanager --licenses

Setting up flutter config

Update flutter config and set path to android sdk directory where it is installed.

$ flutter config --android-sdk /usr/lib/Android
Enter fullscreen mode Exit fullscreen mode

You have to install flutter extension in visual studio code in order use flutter.

creating Emulator

Create emulator with name pixel or choose the name you want

$ avdmanager -s create avd -n pixel -k "system-images;android-29;google_apis;x86_64"
Enter fullscreen mode Exit fullscreen mode

Create emulator using existing devices features

$ avdmanager -s create avd -n pixel -k "system-images;android-29;google_apis;x86_64" -d 19
Enter fullscreen mode Exit fullscreen mode

you can get list of exting devices using

$ avdmanager list
Enter fullscreen mode Exit fullscreen mode

Moment of truth

$ flutter doctor -v
Enter fullscreen mode Exit fullscreen mode

This command should give all green and ok except android studio path.

Run emulator

$ flutter emulator --launch pixel
Enter fullscreen mode Exit fullscreen mode

Here's an image in action:
Emulator

Top comments (19)

Collapse
 
oneohthree profile image
oneohthree

Nice and concise article.

This line: $ sudo mv gradle/ opt/ should read: $ sudo mv gradle/ /opt/.

Collapse
 
jay_js profile image
Jayesh Kale

yeah forgot to mention that thanks for help.

Collapse
 
josedonato profile image
José Donato

good article :D

the line sdkamanger "platform-tools" has a typo --> sdkmanager

Collapse
 
jay_js profile image
Jayesh Kale

yeah corrected it.👍

Collapse
 
kayalla profile image
Kayalla

Worked fine for me, thanks!
Besides noticed that the "$" is missing in variable GRADLE_HOME at "export PATH=GRADLE_HOME/bin:$PATH".

Collapse
 
axmedbadal profile image
axmedbadal

bro thank you in advance
but i have this little small issue will following along your post

sdkmanager "system-images;android-29;google_apis;x86_64"

ERROR: JAVA_HOME is set to an invalid directory: path_to_java_home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

please respond asp

Collapse
 
jay_js profile image
Jayesh Kale

can you check your java home path where it is installed.

Collapse
 
nkristianto profile image
Novian Kristianto

I have downloaded the sdk-tools-linux-4333796.zip, and I can't find the platform-tools directory inside. I'm running on arch-linux

Collapse
 
jay_js profile image
Jayesh Kale • Edited

you won't find platform tools inside it directly.. you have to install it using command -> sdkmanager "platform-tools"

Collapse
 
lilboat72 profile image
Kingsley Manzeke • Edited

If anyone else is trying to executing that code and geting 'Warning: Failed to read or create install properties file.'

Go here askubuntu.com/questions/1227439/18...

Collapse
 
lucsouza profile image
Lucas Eduardo Correa de Souza

Hi, you save my journey to learn flutter. I got and issue with sdk trying to use flutter and Android Studio on ubuntu. Now i can learn thanks to your tutorial. So i join the community to say thanks.

Collapse
 
jay_js profile image
Jayesh Kale

Thats what community for❤️

Collapse
 
lilboat72 profile image
Kingsley Manzeke

Does your ubuntu version have to be '19.04'? Mine is currently 18.04

Collapse
 
jay_js profile image
Jayesh Kale

no it doesn't matter but it at least has to be 18.04 or above wiil be great

Collapse
 
tianna1121 profile image
yang

any plan to expand your work to support debugging flutter apps remotely via vnc+headless android emulator?

Collapse
 
jay_js profile image
Jayesh Kale

no not currently but will research on it.. btw thanks for advice👍

Collapse
 
perymerdeka profile image
perymerdeka

I missing Adb from android SDK how to installed manualy?

Collapse
 
mehulanshumali profile image
Mehul Anshumali

Nice article...
But I have an issue I have done all the steps perfectly but when I tried to launch the emulator it's not launching.
Please help..

Collapse
 
jay_js profile image
Jayesh Kale

can you provide some detailed information on that.