运行“ flutter doctor --android-licenses”时如何解决?

时间:2020-10-22 07:46:47

标签: android flutter

运行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 个答案:

答案 0 :(得分:0)

在Linux中,使用以下命令

export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

对于Windows,请使用以下选项:

set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee

注意:

这不适用于没有Java 11+ EE模块的Java。为此,我建议降级您的Java version或等待Flutter update

答案 1 :(得分:0)

用OpenJDK 8代替OpenJDK 11目前可以解决我的问题。例如:

sudo apt autoremove openjdk-11-*
sudo apt purge openjdk-11-*

sudo apt install openjdk-8-jdk openjdk-8-jdk-headless