好吧,我最近切换到了 ubuntu,我很难弄清楚如何安装所有东西并启动 Flutter 开发。当我运行 flutter doctor 时,我得到了:
[✓] Flutter (Channel stable, 1.22.1, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for
more details.
[!] Android Studio (not installed)
[!] Connected device
! No devices 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:
java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
安装 Flutter 本身很简单。但是我按照多个线程来了解如何在我的计算机上安装 android-jdk,但我觉得我搞砸了。有人可以指导我吗?
答案1
- 打开Android Studio
- 转到“工具”>“SDK 管理器”
- 从左侧选择“外观和行为”>“系统设置”>“Android SDK”
- 从顶部菜单中选择 SDK 工具
- 检查Android SDK 命令行工具并点击应用。
- 运行 flutter doctor --android-licenses