阅读 378

Flutter踩坑之 Android license status unknown 解决方案

问题引入

Mac上搭建Flutter开发环境文章中,在使用flutter doctor查看是否需要安装其它依赖项时,检测出问题! 其中有关Android平台的报错如下:

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.
复制代码

1、输入:

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、未翻墙的电脑先配置临时镜像

PUB_HOSTED_URL			=	https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL	=	https://storage.flutter-io.cn
复制代码

3、在Android studio上安装Flutter的插件默认同时会安装Dart插件

image.png

4、运行flutter doctor 还是报错的话,输入此命令

/Users/用户名/Library/Android/sdk/tools/bin/sdkmanager --update

提示:

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
复制代码

意思就是让安装JRA软件

image.png

5、安装JRA,完成后 ,打开环境变量:

open -e .bash_profile

输入指令查看java安装的路径:(可选择,如果你知道的话,我输出的结果 /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home

/usr/libexec/java_home -V

输入配置环境内容:

JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home"
PATH="$JAVA_HOME/bin:$PATH"
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
复制代码

保存:

source ~/.bash_profile

6、最后:

flutter doctor --android-licenses

于是成功啦:

image.png

文章分类
前端
文章标签