Android Studio

Android Studio is optional if you want to use Flutter. But if you install it you will have two important features:
  • Android SDK to debug and useful commands about Android
  • Emulators to run your application without any Android smartphone
If you don't want Android Studio, it's your choice and you can install it after Flutter. If you want to install just SDK tools, you can download it from official website and install it.
This guide is for Ubuntu 18.04, Android Studio 4 and Flutter 1.20. I give some tips for other distributions.

Installation

On Ubuntu with PPA

Android Studio is not available with APT but on Ubuntu we can add a PPA to add it to APT.

sudo apt-add-repository ppa:maarten-fonville/android-studio
sudo apt install -y android-studio

On another distribution

You have two choices, you can download directly archive on official website or with terminal and wget. If you choose this method, this is an example with a version of Android Studio (september 2020), if you want a recent version, check on official website if you can find most recent Android Studio - you can update link and download it with terminal.

wget -O android-studio.tar.gz "https://redirector.gvt1.com/edgedl/android/studio/ide-zips/4.0.1.0/android-studio-ide-193.6626763-linux.tar.gz"

Move archive to /opt and extract it

sudo mv android-studio*.tar.gz /opt
sudo tar xf /opt/android-studio*.tar.gz

Create an application launcher

vim ~/.local/share/applications/android-studio.desktop
~/.local/share/applications/android-studio.desktop
[Desktop Entry]
Encoding=UTF-8
Name=Android Studio
Exec=/opt/android-studio/bin/studio.sh
# Before v6.1.2
# Icon=/opt/Postman/resources/app/assets/icon.png
Icon=/opt/android-studio/bin/studio.png
Terminal=false
Type=Application
Categories=Development;

After installation
When the package is installed, search Android Studio in your apps and execute it and setup to keep all as default. A wizard will download tools, when tools configuration is finish, you can create an basic project to use IDE.

Platform-tools

~/Android/SdK/tools and ~/Android/SdK/platform-tools are installed when Android Studio is installed and setup. It's tools to work with Android, it's very useful to debug.

In .profile, .bashrc or .zshrc

~/.zshrc
export PATH=${PATH}:/home/ewilan/Android/Sdk/tools
export PATH=${PATH}:/home/ewilan/Android/Sdk/tools:/home/ewilan/Android/Sdk/platform-tools

And check if you have adb command

adb devices
source ~/.zshrc

Virtual device

developer.android.com/emulator-acceleration: Configure VM acceleration on Linux

Open AVD Manager from toolbar or search avd in global search (double tape on N).

Create new device, select phone with PlayStore, like Pixel 2 and select recent Android OS, like Oreo 8.1. Download image to create virtual device and launch it. If you have some problems with KVM check below.

AVD Manager without Android Studio

Android Studio have to be installed, this tip works if you want to launch emulator after create a new device with Android Studio.

List availables emulator devices

~/Android/Sdk/tools/emulator -list-avds

Start an emulator where Pixel_2 is emulator's name

~/Android/Sdk/tools/emulator -avd Pixel_2

Troubles with KVM

If you have this error in AVD Manager

/dev/kvm permission denied

Setup KVM with this

sudo apt install qemu-kvm
ls -al /dev/kvm\n
grep kvm /etc/group\n
sudo adduser $USER kvm

Restart / Logout

If nothing work:

sudo chown $USER /dev/kvm