m1版Mac运行Flutter项目报错:Kotlin could not find the required JDK tools in the Java ...
Posted BennuCTech
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了m1版Mac运行Flutter项目报错:Kotlin could not find the required JDK tools in the Java ...相关的知识,希望对你有一定的参考价值。
本来能过正常运行的Flutter项目,换成m1版的mac后重新安装了android Studio,再用Android真机测试的时候发现运行不起来了,报错如下:
Kotlin could not find the required JDK tools in the Java installation 'xxx' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
根据网上的提示,可能是Flutter环境有问题,运行
flutter doctor -v
发现:
[!] 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
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
问题变成了“Unable to find bundled Java version.”
根据网上的说法,是这个Android Studio缺少文件,进入Android Studio的目录下,把/Contents/jre/Contents中的文件copy到/Contents/jre/jdk/Contents(新建文件夹)中。
然后在运行
flutter doctor -v
发现没问题了,再运行项目就能正常跑起来了。
关注公众号:BennuCTech,获取更多干货!
以上是关于m1版Mac运行Flutter项目报错:Kotlin could not find the required JDK tools in the Java ...的主要内容,如果未能解决你的问题,请参考以下文章
带有 Xcode 12.5 的 M1 Mac 从不运行 Flutter 项目
迁移到 M1 Mac 后在 iOS 上运行 Flutter App 时出错
Flutter 运行和 ipa - Mac M1 - #import <Flutter/Flutter.h>
M1 Mac 上的 Pod 安装错误 - 使用 shared_preferences 等本机代码的 Flutter 项目