Flutter更新Android Studio后无法找到Java Runtime?

Maa*_*tab 5 java android jvm android-studio flutter

我将android studio更新为Electric El,但更新后找不到Java Runtime。

\n

Flutter doctor 给出此错误并且代码无法编译。

\n
maazaftab@maazs-MacBook-Pro edge-focus-mobile % flutter doctor                   \nDoctor summary (to see all details, run flutter doctor -v):\nThe operation couldn\xe2\x80\x99t be completed. Unable to locate a Java Runtime.\nPlease visit http://www.java.com for information on installing Java.\nThe operation couldn\xe2\x80\x99t be completed. Unable to locate a Java Runtime.\nPlease visit http://www.java.com for information on installing Java.\n[\xe2\x9c\x93] Flutter (Channel beta, 3.7.0-1.2.pre, on macOS 13.0.1 22A400 darwin-arm64, locale en-PK)\n[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)\n    \xe2\x9c\x97 Could not determine java version\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 14.1)\n[\xe2\x9c\x93] Chrome - develop for the web\n[!] Android Studio (version 2022.1)\n    \xe2\x9c\x97 Unable to find bundled Java version.\n[\xe2\x9c\x93] IntelliJ IDEA Community Edition (version 2022.3)\n[\xe2\x9c\x93] VS Code (version 1.62.3)\n[\xe2\x9c\x93] Connected device (2 available)\n[\xe2\x9c\x93] HTTP Host Availability\n\n! Doctor found issues in 2 categories.\n\n
Run Code Online (Sandbox Code Playgroud)\n

Maa*_*tab 13

在您的 zshrc 文件中添加。

\n
export JAVA_HOME=/Applications/Android\\ Studio.app/Contents/jbr/Contents/Home\n
Run Code Online (Sandbox Code Playgroud)\n

重新启动android工作室。Flutter doctor 会给出这个。

\n
maazaftab@maazs-MacBook-Pro edge-focus-mobile % flutter doctor\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel beta, 3.7.0-1.2.pre, on macOS 13.0.1 22A400 darwin-arm64, locale en-PK)\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 33.0.1)\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 14.1)\n[\xe2\x9c\x93] Chrome - develop for the web\n[!] Android Studio (version 2022.1)\n    \xe2\x9c\x97 Unable to find bundled Java version.\n[\xe2\x9c\x93] IntelliJ IDEA Community Edition (version 2022.3)\n[\xe2\x9c\x93] VS Code (version 1.62.3)\n[\xe2\x9c\x93] Connected device (2 available)\n[\xe2\x9c\x93] HTTP Host Availability\n
Run Code Online (Sandbox Code Playgroud)\n

您可以忽略警告\xe2\x9c\x97 无法找到捆绑的 Java 版本。但代码会成功编译。

\n