Flutter doctor 运行报错 Unable to find bundled Java version.

一段时间没用,发现运行 Flutter 项目报错, flutter doctor 如下:

(base) xiaoxu@xiaoxudeMacBook-Pro ~ % flutter doctor
  ╔════════════════════════════════════════════════════════════════════════════╗
  ║ A new version of Flutter is available!                                     ║
  ║                                                                            ║
  ║ To update to the latest version, run "flutter upgrade".                    ║
  ╚════════════════════════════════════════════════════════════════════════════╝


Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.3.1 20E241 darwin-arm, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
    ✗ Unable to find bundled Java version.
[✓] VS Code (version 1.62.3)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

解决办法

参考 stackoverflow ,已经有解决方案了,解决方案如下:

cd /Applications/Android\ Studio.app/Contents/jre

ln -s ../jre jdk

ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

flutter doctor -v

不过我研究了一下,我的终端报错找不到这个地址

cd /Applications/Android\ Studio.app/Contents/jre

查了一下,我的 M1 电脑安装的是 preview 版本 Android Studio,所以重新修改了上面的地址,最终解决办法如下

cd /Applications/Android\ Studio\ Preview.app/Contents/jre 

ln -s ../jre jdk

ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

flutter doctor -v

完美解决!

你可能感兴趣的:(Flutter doctor 运行报错 Unable to find bundled Java version.)