Flutter 运行结束于:Could not create an instance of type org.gradle.invocation.DefaultGradle

Posted

技术标签:

【中文标题】Flutter 运行结束于:Could not create an instance of type org.gradle.invocation.DefaultGradle【英文标题】:Flutter run ends with: Could not create an instance of type org.gradle.invocation.DefaultGradle 【发布时间】:2021-12-15 05:27:34 【问题描述】:

由于这个错误,我的 Flutter 项目无法运行:enter image description here

这是我的配置:Flutter 2.5.2 • 通道稳定 • https://github.com/flutter/flutter.git 框架 • 修订版 3595343e20 (4 周前) • 2021-09-30 12:58:18 -0700 引擎 • 修订版 6ac856380f 工具• Dart 2.14.3

医生总结(要查看所有详细信息,请运行 flutter doctor -v):[✓] Flutter (Channel stable, 2.5.2, on Microsoft Windows [Versione 10.0.22000.282], locale it-IT) [✓] android 工具链 - 为 Android 设备开发(Android SDK 版本 30.0.3)[✓] Chrome - 为 网络 [✓] Visual Studio - 为 Windows 开发(Visual Studio 社区 2019 16.11.3) [✓] Android Studio (版本 2020.3) [✓] IntelliJ IDEA 终极版(2021.1 版)[✓] IntelliJ IDEA 终极版(2021.2 版)[✓] VS Code(1.61.2 版)[✓] 连接的设备(4 个可用)

• 未发现任何问题!

----------------------------------------------- ------------- Gradle 7.1

构建时间:2021-06-14 14:47:26 UTC 修订: 989ccc9952b140ee6ab88870e8a12f1b2998369e

Kotlin:1.4.31 Groovy:3.0.7 Ant:Apache Ant(TM) 2020 年 9 月 27 日编译的 1.10.9 版 JVM:1.8.0_281 (Oracle Corporation 25.281-b09) 操作系统:Windows 10 10.0 amd64

我已经搜索过这个问题,但没有适合我的解决方案。

还有比我更幸运的人吗?

【问题讨论】:

【参考方案1】:

问题解决了... 在“gradlew.bat”中你必须设置“JAVA_HOME”指向你最喜欢的JDK,可能是继承自Andoid Studio安装的JDK有问题

【讨论】:

以上是关于Flutter 运行结束于:Could not create an instance of type org.gradle.invocation.DefaultGradle的主要内容,如果未能解决你的问题,请参考以下文章

flutter踩坑01:下载包失败:Could not resolve all artifacts for configuration....

m1版Mac运行Flutter项目报错:Kotlin could not find the required JDK tools in the Java ...

m1版Mac运行Flutter项目报错:Kotlin could not find the required JDK tools in the Java ...

flutter:Could not download kotlin-gradle-plugin.jar

flutter Could not resolve project :path_provider_macos.

flutter Could not resolve project :path_provider_macos.