Last Updated on 2021-10-25 by Clay
Recently, I configured the Android Studio on Linux system for Flutter development, but I encounter the following error when using flutter doctor --android licenses
command (It’s necessary).
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
You may guess that is the Java version mismatch, but even you change the Java version, sometimes you still cannot found the Java module to solve it. You can try to install Android SDK Command-line tools, may be it can help.
Installation
Open the Android Studio’s option Tools > SDK Manager > Appearance & Behavior > System Settings > Android SDK > SDK Tools > Android SDK Command-line tools. Finally select the Apply button.
Back to your terminal, try to use flutter doctor --android licenses
command again, may be you can continue in this time.