安装Flutter遇到的问题
程序员文章站
2022-06-01 14:11:17
...
- 最近忽然想玩玩Flutter,安装的时候遇到了一些问题,在这里记录一下
- 文章来自我的博客,原文链接:https://zhj.forever305.cn/2020/02/24/Flutter-Start/
1. Android license status unknown
下载Flutter SDK,配置环境变量之后,在命令行输入flutter doctor
诊断当前环境
PS C:\Users\ZHJ> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.19564.1000], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 29.0.2)
X Android license status unknown.
[√] Android Studio (version 3.2)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
使用以下命令诊断安卓证书 flutter doctor --android-licenses
PS C:\Users\ZHJ> flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
E:\AndroidStudio\SDK\tools\bin\sdkmanager --update
按照提示,输入相应命令E:\AndroidStudio\SDK\tools\bin\sdkmanager --update
,然而…
PS C:\Users\ZHJ> E:\AndroidStudio\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:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
上网找了一下原因,大概是因为我的 JDK 版本太低了,需要去官网下载JDK1.8版本
重新安装之前,别忘了在控制面板里把原版JDK卸载掉
重新执行E:\AndroidStudio\SDK\tools\bin\sdkmanager --update
PS C:\Users\ZHJ> E:\AndroidStudio\SDK\tools\bin\sdkmanager --update
Warning: File C:\Users\ZHJ\.android\repositories.cfg could not be loaded.
License intel-android-extra-license: ] 10% Computing updates...
之后接受他的安装许可
检查目前状态
PS C:\Users\ZHJ> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.19564.1000], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.2)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
系统提示有一些证书还未被接受,按照提示重新执行flutter doctor --android-licenses
,接受所有条款
PS C:\Users\ZHJ> flutter doctor --android-licenses
Warning: File C:\Users\ZHJ\.android\repositories.cfg could not be loaded.[========= ] 25% F[========= ] 25% Fetch remote repository...
5 of 7 SDK package licenses not accepted. 100% Computing updates...
Review licenses that have not been accepted (y/N)? y
1/5: License android-googletv-license:
---------------------------------------
重新运行自检程序
PS C:\Users\ZHJ> flutter doctor -v
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.19564.1000], locale en-US)
• Flutter version 1.0.0 at E:\Flutter\flutter
• Framework revision 5391447fae (1 year, 3 months ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[√] Android toolchain - develop for Android devices (Android SDK 29.0.2)
• Android SDK at E:\AndroidStudio\SDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = E:\AndroidStudio\SDK
• Java binary at: E:\AndroidStudio\install\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[√] Android Studio (version 3.2)
• Android Studio at E:\AndroidStudio\install
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
可以看到,Android toolchain 问题已经解决了
2. Android Studio Flutter plugin not installed
至于这个问题,直接在 Android Stuio 插件安装界面安装flutter插件即可
安装完成后,重启 Android Studio
如果再启动界面看到 Start a new Flutter project
说明插件安装成功
运行自检程序查看环境状态
PS C:\Users\ZHJ> flutter doctor -v
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.19564.1000], locale en-US)
• Flutter version 1.0.0 at E:\Flutter\flutter
• Framework revision 5391447fae (1 year, 3 months ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[√] Android toolchain - develop for Android devices (Android SDK 29.0.2)
• Android SDK at E:\AndroidStudio\SDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = E:\AndroidStudio\SDK
• Java binary at: E:\AndroidStudio\install\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[√] Android Studio (version 3.2)
• Android Studio at E:\AndroidStudio\install
• Flutter plugin version 31.3.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
OK,现在flutter已经安装完成了
上一篇: 使用Java操作csv文件
下一篇: Python学习:读取csv文件
推荐阅读
-
php中php.ini遇到的问题
-
电脑蓝屏显示:你的电脑遇到问题需要重新启动怎么办?
-
Unity Android安装apk后显示两个app的问题
-
我遇到一个奇怪的问题,php代码里面凡是含有//这样的注释,include 失败
-
qt 连接mysql 遇到的问题
-
今天遇到了很奇葩的li a的点击问题。_html/css_WEB-ITnose
-
Web 开发中遇到的UTF-8的问题总结_PHP
-
MySQL 5安装过程中遇到的问题的解决
-
尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下以 64 位模式运行,将出现此问题。
-
安装discuz mysqli_contect advice_mysqli_connect不支持的问题