相关文章推荐
英俊的槟榔  ·  薛道衡_百度百科·  1 月前    · 
爱逃课的牛腩  ·  ACE Studio - ...·  1 年前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account flutter doctor --android-licenses throws Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema #84325 flutter doctor --android-licenses throws Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema #84325 sbane256 opened this issue Jun 10, 2021 · 15 comments
  • On the installation steps, ran flutter doctor in powershell and it comes up with the following:
  • √] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.18363.1556], 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 (not installed)
    [√] IntelliJ IDEA Community Edition (version 2021.1)
    [√] Connected device (2 available)
    - Then ran flutter doctor --android-licenses:
    - Unrecognized option: -
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.

    I have jdk-16.0.1 installed. Not sure what to do

    @sbane256
    Check above comment and try with JDK 8 to see if it resolves your issue. If it does and running the command again gives you another error like Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema , then you'll need to install Android SDK Command-line tools from Android Studio with which you should be able to accept licenses.

    waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 10, 2021
  • Uninstalled JDK 16
  • Downloaded JDK 8 from https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
  • Made sure and tried to see the version on Powershell:
  • PS C:\Users\banersh> java -version
    java version "1.8.0_291"
    Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
    
  • Ran flutter doctor and still getting the same issue (see below). Also already installed Android SDK command-line tools from Android Studio:
  • **PS C:\Users\banersh> flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.18363.1556], 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 (not installed)
    [√] IntelliJ IDEA Community Edition (version 2021.1)
    [√] Connected device (2 available)**
    ! Doctor found issues in 2 categories.
    PS C:\Users\banersh> flutter doctor --android-licenses
    Unrecognized option: -
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.

    -Tried exiting out and editing variables to include JAVA_HOME and the java/bin in the Path but that didn't help either.

    Any help?

    waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 10, 2021

    Hi @sbane256, sorry that the above didn't work, out of interest do you get the same error running this command?

    & "$Env:ANDROID_SDK_ROOT\tools\bin\sdkmanager" --licenses --verbose

    Hi @tnc1997, I ran the command & "$Env:ANDROID_SDK_ROOT\tools\bin\sdkmanager" --licenses --verbose and got the following:

    PS C:\Users\banersh> & "$Env:ANDROID_SDK_ROOT\tools\bin\sdkmanager" --licenses --verbose
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\build-tools\30.0.3\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\cmdline-tools\latest\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\emulator\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\patcher\v4\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\platform-tools\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\platforms\android-30\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\sources\android-30\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\system-images\android-30\google_apis\x86\package.xml
    Info: Parsing C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk\tools\package.xml
    Warning: File C:\Users\banersh\.android\repositories.cfg could not be loaded.
    License android-googletv-license:=======] 100% Computing updates...

    Terms and Conditions

    This is the Google TV Add-on for the Android Software Development Kit License Agreement.
    There were various licenses agreements after this and I accepted all 7. For example:

    _6 of 7 SDK package licenses not accepted.
    Review licenses that have not been accepted (y/N)? Y

    1/6: License android-googletv-license:_

    Finally got the message:

    Accept? (y/N): Y
    All SDK package licenses accepted_
    I then proceeded to run flutter doctor again cause I thought this would have worked, but it ran into the same issue. Is there a problem with not being able to locate java? Not sure...
    Accept? (y/N): Y
    All SDK package licenses accepted
    PS C:\Users\banersh> flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.18363.1556], 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 (not installed)
    [√] IntelliJ IDEA Community Edition (version 2021.1)
    [√] Connected device (2 available)
    ! Doctor found issues in 2 categories.
    PS C:\Users\banersh> flutter doctor --android-licenses
    Unrecognized option: -
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.

    Hi @sbane256, apologies that didn't work, yeah it looks like an issue with Flutter & Java for some reason. Are there any additional details that you might be able to share by running flutter doctor --verbose? Here's my output for reference:

    flutter doctor -v
    PS C:\Windows\system32> flutter doctor --verbose
    [✓] Flutter (Channel dev, 2.3.0-12.1.pre, on Microsoft Windows [Version 10.0.19043.1052], locale en-GB)
        • Flutter version 2.3.0-12.1.pre at C:\Tools\flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision f9c825981c (3 weeks ago), 2021-05-18 14:07:52 -0700
        • Engine revision 26e217e6c3
        • Dart version 2.14.0 (build 2.14.0-edge.a527411e5100a0a4f48c4009087a1b988aa784af)
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at C:\Users\tnc19\AppData\Local\Android\Sdk
        • Platform android-S, build-tools 30.0.2
        • ANDROID_SDK_ROOT = C:\Users\tnc19\AppData\Local\Android\Sdk
        • Java binary at: C:\Program Files\AdoptOpenJDK\jdk-8.0.292.10-hotspot\bin\java.exe
        • Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
        • All Android licenses accepted.
    [✓] Chrome - develop for the web
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    [✓] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.10.0)
        • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
        • Visual Studio Build Tools 2019 version 16.10.31321.278
        • Windows 10 SDK version 10.0.18362.0
    [!] Android Studio (not installed)
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
        • IntelliJ at C:\Users\tnc19\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\212.4037.9
        • Flutter plugin installed
        • Dart plugin version 212.4037.9
    [✓] Connected device (3 available)
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19043.1052]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 90.0.4430.212
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 91.0.864.41
    ! Doctor found issues in 1 category.
    flutter doctor -v
    Windows PowerShell
    Try the new cross-platform PowerShell https://aka.ms/pscore6
    PS C:\Users\banersh> flutter doctor --verbose
    [√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.18363.1556], locale en-US)
        • Flutter version 2.2.0 at C:\Users\banersh\OneDrive - EY\Desktop\Flutter\flutter
        • Framework revision b22742018b (4 weeks ago), 2021-05-14 19:12:57 -0700
        • Engine revision a9d88a4d18
        • Dart version 2.13.0
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_SDK_ROOT = C:\Users\banersh\OneDrive - EY\Desktop\Flutter\android-sdk
        • Java binary at: C:\Program Files\Java\jdk1.8.0_291\bin\java
        • Java version Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
        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
        • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    [!] Android Studio (not installed)
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
    [√] IntelliJ IDEA Community Edition (version 2021.1)
        • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1
        • Flutter plugin can be installed from:
           https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
           https://plugins.jetbrains.com/plugin/6351-dart
    [√] Connected device (2 available)
        • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77
        • Edge (web)   • edge   • web-javascript • Microsoft Edge 91.0.864.41
    ! Doctor found issues in 2 categories.
    PS C:\Users\banersh> flutter doctor --android-licenses
    Unrecognized option: -
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    PS C:\Users\banersh>

    Unrecognized option: - seems to be incomplete, so can't really know what option is it pointing to. Usually it points to an exe or module which is not recognized.

    Keeping this open for further investigation from team.

    Flutter doctor - android licenses issues Flutter doctor --android-licenses shows Unrecognized option: - Error: Could not create the Java Virtual Machine. Jun 11, 2021 flutter doctor -v
    ~ flutter doctor
    Running "flutter pub get" in flutter_tools...                       5.8s
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale
        zh-Hans-CN)
    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for
          more details.
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 4.2)
    [✓] VS Code (version 1.57.1)
    [✓] Connected device (2 available)~ 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~ java -version
    openjdk version "1.8.0_212"
    OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
    OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)
    changed the title Flutter doctor --android-licenses shows Unrecognized option: - Error: Could not create the Java Virtual Machine. flutter doctor --android-licenses throws Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema Jul 13, 2021

    Hi @sbane256 and everyone
    First, make sure you've also installed cmd tools and then flutter doctor --android-licenses

    If the problem persists, I am not sure where I read it but this is likely a bug with this particular java version too

    C:\Users\Taha\Code\android-studio\jre\bin\java

    My Java path is set to default JDK that comes with Android Studio itself, which java 11, and there is no issue when executing flutter doctor --android-licenses

    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at C:\Users\Taha\Code\android-sdk
        • Platform android-30, build-tools 30.0.3
        • ANDROID_SDK_ROOT = C:\Users\Taha\Code\android-sdk
        • Java binary at: C:\Users\Taha\Code\android-studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
        • All Android licenses accepted.

    Hope this helps

    waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 13, 2021

    i do have same issue that why i installed the java 8 from oracle and set JAVA_HOME but i ran below issue

    C:\Windows\system32>flutter doctor --android-licenses
    ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_29
    Please set the JAVA_HOME variable in your environment to match the
    location of your Java installation.
    

    Then i follow the #84325 (comment) and install Android SDK Command line tools. After that i run flutter doctor --android-licenses , still throw java_home error then i removed environment variable JAVA_HOME then i restart my system and run flutter doctor --android-licenses then it works.
    Conclusion : No need to setup external jdk 8 or any version.

    Thanks TahaTesser and other

    waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 21, 2021