Flutter Doctor –android-licenses : Exception in thread “main” java.lang.NoClassDefFoundError

0

Flutter Error – Flutter Doctor –android-licenses : Exception in thread “main” java.lang.NoClassDefFoundError

Sometimes flutter won't accept the android license. It will get the following error:

C:\Users\Chamara>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:522)
        ... 5 more

This is what flutter doctor returns:

flutter-doctor-android-licenses-exception-in-thread-main-java-lang-noclass
flutter-doctor-android-licenses-exception-in-thread-main-java-lang-noclass

We have two methods to solve this problem.

Method 1

Installing Android SDK Command-line tools from Android SDK Manager did the job for me.

  1. Open Android Studio
  2. Tools > SDK Manager
  3. From the left choose, Appearance & Behavior > System Settings > Android SDK
  4. Select SDK Tools from the top menu
  5. Check Android SDK Command-line tools and click ‘apply'.
Installing Android SDK Command-line tools android studio
Installing Android SDK Command-line tools android studio

Method 2

May be you still not have Java install on your computer. So install java from https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

After check for your JAVA_HOME path under System Variables it should be like:

C:\Program Files\Java\jre1.8.0_291
(no semi-colon and no \bin)

JAVA_HOME path under System Variables
JAVA_HOME path under System Variables

restart terminal and try again with:

 flutter doctor --android-licenses

if still, you are getting any error feel free to Contact Us. or Ask from our Community.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
CodeROG
Logo
Reset Password
Compare items
  • Total (0)
Compare
0
Shopping cart