Flutter Doctor --android-licenses : Exception in thread "main" java.lang.NoClassDefFoundError
Solution 1
Installing Android SDK Command-line tools from Android SDK Manager did the job for me.
- Open Android Studio
- Tools > SDK Manager
- From the left choose, Appearance & Behavior > System Settings > Android SDK
- Select SDK Tools from the top menu
- Check Android SDK Command-line tools and click 'apply'.
Solution 2
Firstly check for your JAVA_HOME path under System Variables it should be like -->
C:\Program Files\Java\jdk-15.0.2
(no semi-colon and no \bin)
and add to path (in System Variables)--> %JAVA_HOME%\bin
if still, you are getting any error try this in Android Studio--> Setting(Appearance & Behavior) -> Android SDK -> check and download Android SDK Command-line tools.
restart terminal and try again with flutter doctor --android-licenses
--> this should do the work.
Comments
-
Little Ball almost 3 years
I'm trying to install flutter but it won't let me accept the android license. I get the following error:
PS C:\Users\XXXX> 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: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
I've already uninstalled my current version of Java and clean installed Java 8 from here.
This is what
flutter doctor
returns:[✓] Flutter (Channel stable, 1.22.3, on Microsoft Windows [Version 10.0.18363.1139], locale en-IE) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [!] Android Studio (version 4.1.0) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [✓] VS Code (version 1.50.1) [!] Connected device ! No devices available
-
Napoleon over 3 yearsHad the same issue this answer fixed it for me. Thanks.
-
samiq over 3 yearsthanks, this fixed it for me on Big Sur
-
stib about 3 yearsFixed it on Windows 10 too.
-
B. Colin Tim about 3 yearsThis is not true. The issue is caused by the CL-toole missing as the accepted answer suggests. Android Studio does not install them by default as it seems.
-
Bitlejuce Do almost 3 yearsThanks, it did solve the issue! I wonder how people find the solution like this?))
-
BingLi224 almost 3 yearsFor cmdline-tools without Android Studio, call
sdkmanager "cmdline-tools;latest"
in command line instead. -
lwin moe hein almost 3 yearsworked for me, thanks
-
Nishanth Nair almost 3 yearsThis answer saved my day. Thank you!
-
Imam T almost 3 yearsThanks. It helped me fix issues in Catalina.
-
Arafat almost 3 yearsworked for me, thanks
-
Rashesh Bosamiya almost 3 yearsThis worked for me, Thanks!
-
Aghiad Alzein over 2 yearsWorked for Ubuntu thanks a lot