Setting up flutter without Android studio
Jayesh Kale

Jayesh Kale @jay_js

About: Computer programmer craving for awesome things and who think he is sarcastic.

Location:
Pune
Joined:
Jun 6, 2019

Setting up flutter without Android studio

Publish Date: Sep 17 '19
67 19

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

Comments 19 total

  • oneohthree
    oneohthreeDec 2, 2019

    Nice and concise article.

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

    • Jayesh Kale
      Jayesh KaleJan 29, 2020

      yeah forgot to mention that thanks for help.

  • yang
    yangJan 8, 2020

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

    • Jayesh Kale
      Jayesh KaleJan 29, 2020

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

      • perymerdeka
        perymerdekaJun 4, 2021

        I missing Adb from android SDK how to installed manualy?

  • Kayalla
    KayallaJan 16, 2020

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

  • José Donato
    José DonatoJan 27, 2020

    good article :D

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

  • axmedbadal
    axmedbadalFeb 10, 2020

    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

    • Jayesh Kale
      Jayesh KaleFeb 16, 2020

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

  • Lucas Eduardo Correa de Souza
    Lucas Eduardo Correa de SouzaMar 4, 2020

    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.

    • Jayesh Kale
      Jayesh KaleMar 19, 2020

      Thats what community for❤️

  • Novian Kristianto
    Novian KristiantoApr 12, 2020

    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

    • Jayesh Kale
      Jayesh KaleApr 17, 2020

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

  • Kingsley Manzeke
    Kingsley ManzekeApr 17, 2020

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

    • Jayesh Kale
      Jayesh KaleApr 17, 2020

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

  • Mehul Anshumali
    Mehul AnshumaliJul 28, 2020

    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..

    • Jayesh Kale
      Jayesh KaleAug 8, 2020

      can you provide some detailed information on that.

Add comment