[SOLVED] Flutter Android licenses exception

If you are here it means that you are facing a frustrating exception regarding Android licenses in Flutter.

More specifically the exception occurs when you try to run the following command:

$ flutter doctor --android-licenses

and the output is something like this:

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

The easiest fix I found is to install the Android SDK Command-line Tools.

In Android Studio open

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

then tick the corresponding element, install and restart Android Studio and everything shoul work like a charm.

Happy coding!




This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

48 thoughts on “[SOLVED] Flutter Android licenses exception”

  1. Thank you so much😍❀
    I tried many solutions but just this solution worked.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.