flutter doctor --android-licenses gives a java error

0 votes
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

I get this error above when running flutter doctor --android-licenses. Does anyone know why this is happening and how I can fix it? I'm already running it on the flutter console.

Mar 23, 2023 in Flutter by Ashwini
• 5,430 points
3,896 views

1 answer to this question.

0 votes

This error usually occurs because the Java version installed on your machine is not compatible with the Android SDK Manager. To fix this issue, you can try the following steps:

  1. Ensure that you have installed the latest version of Java on your machine. You can download it from the official Java website.

  2. Check if the JAVA_HOME environment variable is set correctly. To do this, open your terminal or command prompt and type the following command:

    echo $JAVA_HOME

    If the output is blank or incorrect, you need to set the JAVA_HOME variable to the correct path. You can find the path to your Java installation by running the following command:

    which java

    This will return the path to the Java executable.

  3. Once you have set the JAVA_HOME variable, try running the command flutter doctor --android-licenses again.

  4. If the issue persists, try adding the following lines to your gradle.properties file:

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
  1. The gradle.properties file can be found in the android/ directory of your Flutter project.

  2. If none of these steps work, try uninstalling and reinstalling the Android SDK Manager. Make sure to download the latest version from the official Android website.

I hope this helps! Let me know if you have any other questions.

To know more, join our Flutter Training today.

answered Mar 24, 2023 by venky

Related Questions In Flutter

0 votes
1 answer
0 votes
1 answer

How to change Android minSdkVersion in Flutter Project?

Yes, you can change the minSdkVersion in ...READ MORE

answered Mar 21, 2023 in Flutter by Tej
8,800 views
0 votes
1 answer

How do you change the value inside of a textfield flutter?

To change the value inside a TextField ...READ MORE

answered Mar 26, 2023 in Flutter by Tej
7,464 views
0 votes
1 answer

What is Flutter?

Flutter is a free and open-source mobile ...READ MORE

answered Mar 1, 2023 in Android by vishalini
589 views
0 votes
1 answer

Dart SDK is not configured

The error message "Dart SDK is not ...READ MORE

answered Mar 9, 2023 in Android by pooja
14,376 views
0 votes
1 answer

How to log data to the Flutter console?

To log data to the Flutter console ...READ MORE

answered Mar 27, 2023 in Flutter by anonymous
6,416 views
0 votes
1 answer

Flutter command not found

This error message usually appears when the ...READ MORE

answered Mar 29, 2023 in Flutter by vishalini
12,523 views
0 votes
1 answer

Flutter Projects & Android X Migration Issues

Migrating to AndroidX can be a frustrating ...READ MORE

answered Mar 20, 2023 in Flutter by Tej
301 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP