1、flutter doctor --android-licenses报错
odd@Mac-mini flutterdemo % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.1.0-11.0.pre.145, on macOS 12.0.1 21A559 darwin-x64, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1)
[✓] VS Code (version 1.62.3)
[✓] Connected device (3 available)
! Doctor found issues in 2 categories.
odd@Mac-mini flutterdemo % 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:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
解决方式:Install Android SDK Command-line tools
MAC上: Android Studio
->Preference
2、Unable to find bundled Java version.
路径不对,需要调整
在安装的flutter路径里:flutter/packages/flutter_tools/lib/src/android/android_studio.dart
android_studio.dart代码里加载设置如下:
final String javaPath = globals.platform.isMacOS ?
globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home') :
globals.fs.path.join(directory, 'jre');
Android Studio的路径里,没有jdk文件,如下:
1、在Find里的应用程序
里,选中Android Studio
, 然后右键显示包内容
;
2、Contents
->jre
->Contents
,
3、发现jre文件夹里没有jdk
这个文件夹,
4、在jre文件夹里新建jdk
文件,并把jre中的Contents文件夹
整个复制添加到jdk里,
5、添加后jre下有两个文件Contents,jdk, 路径:
Contents
->jre
->Contents
,
Contents
->jre
->jdk
->Contents
,
网友评论