Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter doctor --android-licenses gives a java error

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.

like image 449
Vivek Kogilathota Avatar asked Sep 26 '22 05:09

Vivek Kogilathota


People also ask

How do I fix android toolchain error in flutter?

How to solve Android toolchain – develop for Android devices? This error is occurs because of flutter cant find command line tools in your environment. So that to solve cmdline-tools component is missing Error in Flutter we have to manually download and install the command line tools in android SDK manager.

Why does flutter doctor say android studio not installed?

Search for “flutter” and install this plugin together with dart. Restart the Android Studio and open a new terminal. You should be able to create a flutter project in Android Studio and “flutter doctor” should work now.


2 Answers

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

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

Alternative to step #1: WINDOWS: File > Settings (Ctrl+Alt+S) / MAC : Android Studio > Preferences

This fix works for Windows, Linux and Mac OS X.


enter image description here

If you are facing a problem in spite of the above steps, you can try upgrading your system to JDK 8. Official documentation of upgrading to JDK 8 is available here.

like image 707
sariDon Avatar answered Oct 19 '22 15:10

sariDon


I'm a Mac user and I solve this issue.

This answer also helps Windows users and Linux users solve the issue from the user's feedback.

At the first, this is what I met for the issue
$ flutter doctor -v enter image description here

And the following command is not work for my situation.
$ flutter doctor --android-licenses enter image description here

The way to solve this is to install
Android SDK Command-line Tools. And how?
You just need to do it by the following two steps.

Install: Android SDK Command-line Tools

Step 1. Open SDK Manager
Top Menu -> Tools -> SDK Manager enter image description here

Step 2. Install command-line tools

  1. Unfold Appearance & Behavior
  2. Unfold System Settings
  3. Click Android SDK
  4. Click tab of SDK Tools
  5. Check Android SDK Command-line Tools (latest)
  6. Click Apply button. enter image description here Then click OK button to finish installation.

Keep going to sign android licenses.

After Android Studio finishing install, you can do the following.
$ flutter doctor --android-licenses
enter image description here After saying yes many times, all android licenses have been signed.

Check by flutter doctor again.

$ flutter doctor -v
enter image description here

You can see that All Android licenses accepted.

Congratulations, you have completed this task!

like image 161
Milo Chen Avatar answered Oct 19 '22 17:10

Milo Chen