本文主要是介绍Unable to find bundled Java version =>Mac Flutter问题 Android Studio Arctic Fox 2020.3.1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
终端: flutter doctor -v
1. 问题: android studio 提示 Unable to find bundled Java version
[!] Android Studio (version 2020.3)• Android Studio at /Applications/Android Studio Preview.app/Contents• Flutter plugin can be installed from:🔨 https://plugins.jetbrains.com/plugin/9212-flutter• Dart plugin can be installed from:🔨 https://plugins.jetbrains.com/plugin/6351-dart✗ Unable to find bundled Java version.• Try updating or re-installing Android Studio.
处理方式: 终端输入以下指令
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
完美结果:
[✓] Android Studio (version 2020.3)• Android Studio at /Applications/Android Studio.app/Contents• Flutter plugin can be installed from:🔨 https://plugins.jetbrains.com/plugin/9212-flutter• Dart plugin can be installed from:🔨 https://plugins.jetbrains.com/plugin/6351-dart• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
2 问题
[!] 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/macos#android-setup for more details.
终端输入:flutter doctor --android-licenses 出现如下报错
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchemaat 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.XmlSchemaat 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
处理方法
1. 更新下Android SDK的tools/bin目录下的sdkmanager
终端输入:/Users/***/tools/bin/sdkmanager --update
2. 配置JAVA_HOME
mac下的jdk都默认安装在/Library/Java/JavaVirtualMachines
下面。真实路径如下图所示:
WJdeMacBook-Pro:~ wj$ cd /Library/Java/JavaVirtualMachines
WJdeMacBook-Pro:JavaVirtualMachines wj$ ls -la
total 0
drwxr-xr-x 3 root wheel 96 3 21 15:25 .
drwxr-xr-x 4 root wheel 128 1 1 2020 ..
drwxr-xr-x 3 root wheel 96 4 3 2019 jdk1.8.0_77.jdk
参照苹果的文件文档说明,在命令 /usr/libexec/java_home 后面使用-V选项列出所有版本的JAVA_HOME,即如下的结果:
WJdeMacBook-Pro:JavaVirtualMachines wj$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):1.8.77.03 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home1.8.0_77 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
挑选自己需要的jdk版本,配置到.bash_profile中
终端输入:
1. open .bash_profile
2. export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
3. 上述2配置路径复制搭配 .bash_profile文件中
4. 保存之后,为了让配置立即生效,需要执行:source ~/.bash_profile命令
再次终端输入:flutter doctor
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)! Some Android licenses not accepted. To resolve this, run: flutter doctor--android-licenses
终端输入: flutter doctor --android-liceses
出现多次:Review licenses that have not been accepted (y/N)? 一律输入:y再按回车键
完美结果:
WJdeMacBook-Pro:~ wj$ flutter doctor
***
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
***
这篇关于Unable to find bundled Java version =>Mac Flutter问题 Android Studio Arctic Fox 2020.3.1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!