After installing flutter on my development environment, I face flutter doctor android license issue while I was checking the installation with below command:
flutter doctor --android-licenses
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:521)
... 5 more
That was not the expected result as I follow the installation instructions step by step documented on flutter official site.
I could successfully fix the issue by simply install install Android SDK command line tool from the Android SDK Manager, in order to do that, follow the below steps
- Start Android Studio
- Go to Tools > click on SDK Manager
- From the left-hand side choose, Appearance & Behavior then System Settings then Android SDK
- from the tabs, Select SDK Tools
- Check Android SDK Command-line tools
- click ‘apply’.
Below screenshot is showing the settings popup (I have dark theme on Android Studio)
If you are still facing issues after applying above steps, consider upgrading JDK to the latest. here is the Java official upgrading JDK 8 (latest at this moment)