You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新Android Studio Electric Eel后Flutter无法定位Java Runtime

Android Studio Electric Eel版本找不到Java Runtime的解决办法

问题描述

更新Android Studio到Electric Eel(2022.1版本)后,系统无法识别Java Runtime,执行flutter doctor报错,代码无法编译,具体报错信息如下:

maazaftab@maazs-MacBook-Pro edge-focus-mobile % flutter doctor                   
Doctor summary (to see all details, run flutter doctor -v):
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Flutter (Channel beta, 3.7.0-1.2.pre, on macOS 13.0.1 22A400 darwin-arm64, locale en-PK)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ Could not determine java version
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[!] Android Studio (version 2022.1)
    ✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Community Edition (version 2022.3)
[✓] VS Code (version 1.62.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 2 categories.

解决方案

方法1:配置环境变量指定自带JDK

Android Studio Electric Eel自带JDK,只需手动配置JAVA_HOME指向它:

  • 打开终端,执行以下命令设置环境变量:
    • 若使用Zsh:
      echo 'export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"' >> ~/.zshrc
      source ~/.zshrc
      
    • 若使用Bash:
      echo 'export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"' >> ~/.bash_profile
      source ~/.bash_profile
      
  • 验证配置:
    java -version
    flutter doctor
    
    能正常显示Java版本且flutter doctor不再报Java相关错误即为成功。

方法2:在Android Studio中指定JDK路径

  • 打开Android Studio,依次进入File > Project Structure > SDK Location
  • 在JDK location栏中选择路径:/Applications/Android Studio.app/Contents/jbr/Contents/Home
  • 点击Apply保存,重启Android Studio后重新运行flutter doctor。

方法3:重装Android Studio(备选)

若前两种方法无效,卸载当前版本后重新下载安装Android Studio Electric Eel,安装时确保勾选JDK相关组件。

内容的提问来源于stack exchange,提问作者Maaz Aftab

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 09:45:41