Fix Flutter Android licenses exception

Development flutter android mobile exception
Reading time: 1 minute, 0 seconds

During Flutter installation, you must control your configuration with the command:

$ flutter doctor

I the report generated, you will accept the Android licenses with the command :

$ flutter doctor --android-licenses

But the output can be something like :

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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more

To fix this issue you must install the Android SDK Command-line Tools.

The simpliest method to do it, is through Android Studio.

In menu

File > Settings > Appeareance & Behavior > System Settings > Android SDK > SDK Tools

AndroidStudio

select necessary elements and restart Android Studio.

Now, if you run the command

$ flutter doctor

everything should work !

FlutterDoctor

Next Post Previous Post