Flutter : Android license status unknown.


Flutter : Android license status unknown.

> flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.16299.1004], locale zh-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
X Android license status unknown.
[√] Android Studio (version 3.3)
[!] Connected device
! No devices available


> flutter doctor --android-licenses

A newer version of the Android SDK is required. To update, run:
D:\apps\Android\SDK\tools\bin\sdkmanager --update

> D:\apps\Android\SDK\tools\bin\sdkmanager --update

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:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 5 more

出现以上这种情况,在把jdk版本降到1.8即可解决。

另外,在切换JAVA_HOME后,用java -version 查看版本,显示的版本号不变,原因是环境变量里多出一行:

C:\ProgramData\Oracle\Java\javapath

把%JAVA_HOME%\bin 移动到最前面,或者直接删除这一行。

> java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

> java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

最后执行
> flutter doctor –android-licenses

一路接受。

! No devices available

这个在Android Studio 里面启个模拟器即可。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注