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
Installing Packages
We are installing it by following below steps respectively:
- Navigate to folder where you downloaded your binaries.
- Extract it and move it to relevant location.
- 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
#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
Flutter
$ tar xvf flutter_linux_v1.9.1+hotfix.2-stable.tar.xz
$ sudo mv flutter/ /usr/lib
#flutter
export FLUTTER_HOME=/usr/lib/flutter
export PATH=$FLUTTER_HOME/bin:$PATH
Gradle
$ unzip gradle-5.6.2-bin.zip
$ mkdir gradle
$ mv gradle-5.6.2/ gradle/
$ sudo mv gradle/ /opt
#gradle
export GRADLE_HOME=/opt/gradle/gradle-5.6.2
export PATH=$GRADLE_HOME/bin:$PATH
OpenJDK 8
- Open synaptic package manager if you don't have it install via
$ sudo apt install synaptic
- Type in OpenJDK 8 to search bar.
- Select
- openjdk-8-jdk
- openjdk-8-jdk-headless
- openjdk-8-jre
- 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"
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
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"
Create emulator using existing devices features
$ avdmanager -s create avd -n pixel -k "system-images;android-29;google_apis;x86_64" -d 19
you can get list of exting devices using
$ avdmanager list
Moment of truth
$ flutter doctor -v
This command should give all green and ok except android studio path.
Run emulator
$ flutter emulator --launch pixel
Top comments (19)
Nice and concise article.
This line:
$ sudo mv gradle/ opt/
should read:$ sudo mv gradle/ /opt/
.yeah forgot to mention that thanks for help.
good article :D
the line
sdkamanger "platform-tools"
has a typo --> sdkmanageryeah corrected it.π
Worked fine for me, thanks!
Besides noticed that the "$" is missing in variable GRADLE_HOME at "export PATH=GRADLE_HOME/bin:$PATH".
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
can you check your java home path where it is installed.
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
you won't find platform tools inside it directly.. you have to install it using command -> sdkmanager "platform-tools"
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...
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.
Thats what community forβ€οΈ
Does your ubuntu version have to be '19.04'? Mine is currently 18.04
no it doesn't matter but it at least has to be 18.04 or above wiil be great
any plan to expand your work to support debugging flutter apps remotely via vnc+headless android emulator?
no not currently but will research on it.. btw thanks for adviceπ
I missing Adb from android SDK how to installed manualy?
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..
can you provide some detailed information on that.