简体   繁体   中英

Flutter and Android Studio cannot find Java on Apple M1 running macOS Ventura

flutter doctor -v fails due to missing Java:

[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-US)
    • Flutter version 3.3.10 on channel stable at /opt/homebrew/Caskroom/flutter/3.3.10/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (4 weeks ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/hahnemann/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Library/Java/JavaVirtualMachines/temurin-19.jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment Temurin-19.0.1+10 (build 19.0.1+10)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2022.1)
    • 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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.74.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.48.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.1 22C65 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 109.0.5414.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

I have Java installed from Adoptium using Brew . I already tried flutter doctor --android-licenses and removed the obsolete version of Android SDK Tools:

在此处输入图像描述

What could be wrong?

Apparently it's an open issue with Android Studio Electric Eel 2022.1.1 after I upgraded using Brew. The workaround is:

cd /Applications/Android\ Studio.app/Contents
ln -s jbr jre

On Linux Operating System do this

cd /opt/android-studio

then

ln -s jbr jre 

For Windows you can try this:

  1. Open a terminal with admin permissions (eg Press Win and type "cmd", "powershell" or "terminal", whatever you prefer, and press Ctrl + Shift + Enter )

  2. Then type:

     cd C:\Program Files\Android\Android Studio mklink /D "jre" "jbr"

Hints

If you have installed Android Studio in a different directory change the path.
If there is a almost jre directory you can simply delete it with rmdir /s jre this was the case on my system after an update to Electric Eel (2022.1.1).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM