Installing

Java

The Android SDK manager has known issues with Java 11. If you have Java 11 installed, you have two not-too-complicated alternatives under Ubuntu: downgrade to Java 8, or upgrade to Java 14 (I chose the latter). They are available through apt as packages openjdk-8-jdk and openjdk-14-jdk (and you should absolutely be running the JDK, not the JRE as gradle will complain about that on building, which can be a pain in the ass).

To choose the right version of Java, run

sudo update-alternatives --config java

and pick your preferred version. Then run java -version just to double-check the version.

Flutter

You can always follow the official guidelines; either way, here are the commands you need to run:

sudo snap install --classic flutter

To check if everything is working properly, run

flutter doctor

to diagnose possible problems, and try to fix them.

Android Studio

Run

sudo snap install --classic android-studio

Then open it, select all default options, and install the Flutter and Dart plugins. Now, restart Android Studio, and create a new Flutter project.

Project

It is possible that you might have to change the gradle version. After doing that, try to compile by selecting โ€œRunโ€ in the upper right corner (you have to select a VM first).

Licenses

If it complains about not having accepted some licenses, open the shell, go to ~/Android/Sdk/tools/bin, run ./sdkmanager --licenses and accept all licenses. Now try to recompile, and it should hopefully (and finally!) work.

If ./sdkmanager --licenses fails (most notably if youโ€™re using Java 14) with message

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
	at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
	at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
	at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 5 more

then the easiest solution is really to install openjdk-8-jdk, change the current Java version to 8, run ./sdkmanager --licenses and swap again to Java 14. This solution seems pretty dumb, but I find it quite easier than manually changing code you havenโ€™t written, as suggested here.