Unable to find bundled Java version =>Mac Flutter [Android Studio Arctic Fox 2020.3.1]

Terminal: flutter doctor -v
1. problem: android studio prompts 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.

Treatment method:

cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

Perfect result:

[✓] 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 questions

[!] 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.

Terminal input: Shuttle doctor — Android licenses. The following error is reported

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

Treatment method

one   Update the SDK manager in the tools/bin directory of the Android SDK

Terminal input:/users/* * */tools/bin/sdkmanager — update

2. Configure Java_ HOME

JDK under MAC is installed under /library/Java/javavirtualmachines by default. The real path is shown in the figure below:

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

Refer to Apple’s documentation for the command/usr/libexec/Java_ Use the – V option after home to list all versions of Java_ Home, i.e. the following results:

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/Home
    1.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

Select the JDK version you need and configure it to. Bash_ In profile

Terminal input:

one     open .bash_ profile

two     export JAVA_ HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_ 212.jdk/Contents/Home

export PATH=$JAVA_ HOME/bin:$PATH

three   The above 2 configuration paths are copied with. Bash_ In profile file

four   After saving, in order for the configuration to take effect immediately, you need to execute: source ~ /. Bash_ Profile command

Input: fluent doctor at the terminal again

[!] 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

Terminal input: fluent doctor — Android liceses

Multiple occurrences: review licenses that have not been accepted (Y/N)?        All input: y and then press enter

Perfect result:

WJdeMacBook-Pro:~ wj$ flutter doctor
***
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
***

Read More: