Cant run flutter doctor - - license

282 views Asked by At
C:\Users\USER>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):

[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19042.928], locale en-US)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    X 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.

[√] Chrome - develop for the web

[√] Android Studio

[√] VS Code (version 1.56.1)

[√] Connected device (2 available)

! Doctor found issues in 1 category.

C:\Users\USER>flutter doctor --android-licenses

Error: Could not find or load main class J\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\\..
Caused by: java.lang.ClassNotFoundException: J\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\\//

EDIT 1:

I tried reinstalling sdk (after deleting files completely from appdata/android/sdk). it kinda worked but now new error is showing.:

C:\Users\USER>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
2

There are 2 answers

0
AtmoZki On

After a lot of searching and a lot of diff types of error ranging from environmental variable errors and java errors, i just uninstalled android studio, java and flutter files deleted appdatas etc. and reinstalled it again now flutter doctors works fine.

i know this is not a good solution but someone could try this if all else fails. thks

0
James Z. On

The crux of this issue seem to be with spaces in the Android SDK path, e.g. if your user name on windows is "John Smith", it will fail to detect the android SDK. The solution is to move 'C:\Users\John Smith\AppData\Local\Android\Sdk' to a path with no spaces, e.g. 'C:\Android\Sdk'. Then run the following

flutter config --android-sdk "C:\Android\Sdk"

PS: for a related issue where it says "[!] Android Studio (not installed)", run the following to manually point it to the default Android Studio install location

flutter config --android-studio-dir "C:\Program Files\Android\Android Studio"