如何修复“无法找到或加载主类 org.gradle.launcher.daemon.bootstrap.GradleDaemon”?

Posted

技术标签:

【中文标题】如何修复“无法找到或加载主类 org.gradle.launcher.daemon.bootstrap.GradleDaemon”?【英文标题】:How to fix "Could not find or load main class org.gradle.launcher.daemon.bootstrap.GradleDaemon" in flutter? 【发布时间】:2019-12-18 13:49:37 【问题描述】:

我已经设置了我的新 PC,但我已经在使用 Flutter 时遇到了一些问题。它曾经在我的旧电脑上运行良好。 我已经安装了 android Studio、Android SDK、Flutter、带有 Dart 和 Flutter 插件的 VS Code,然后创建了新的 Flutter 项目。将手机连接到 PC 并按 F5 后出现此错误:

* Error running Gradle:
ProcessException: Process "D:\FlutterProjects\quotes\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)


FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.10.2/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error: Could not find or load main class org.gradle.launcher.daemon.bootstrap.GradleDaemon


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
  Command: D:\FlutterProjects\quotes\android\gradlew.bat app:properties

Please review your Gradle project setup in the android/ folder.

Flutter 医生看起来不错。 这是我的 gradle-wrapper.properties:

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

还有 gradle.properties:

org.gradle.jvmargs=-Xmx1536M
org.gradle.daemon=true
org.gradle.parallel=true

最后一件事,build.gradle:

buildscript 
    repositories 
        google()
        jcenter()
    

    dependencies 
        classpath 'com.android.tools.build:gradle:3.2.1'
    


allprojects 
    repositories 
        google()
        jcenter()
    


rootProject.buildDir = '../build'
subprojects 
    project.buildDir = "$rootProject.buildDir/$project.name"

subprojects 
    project.evaluationDependsOn(':app')


task clean(type: Delete) 
    delete rootProject.buildDir

谁能帮我解决这个问题?

【问题讨论】:

如果你禁用守护进程,它是否会构建 - org.gradle.daemon=false 禁用守护进程也会发生同样的事情 即使您从命令行运行D:\FlutterProjects\quotes\android\gradlew.bat app:properties(即不是从AndroidStudio,没有启用守护程序)? 据我所知,它仍在尝试启动 gradle 守护进程:/ 我尝试使用 D:\FlutterProjects\quotes\android\gradlew.bat app:properties --no-daemon 运行它,现在我收到此错误:Project 'app' not found in根项目“引号”。 【参考方案1】:

运行

flutter clean

它将清理您当前的构建文件夹和缓存,然后当您运行 Flutter App 时,将创建一个新的构建文件夹。

在大多数情况下它会修复​​它。

【讨论】:

以上是关于如何修复“无法找到或加载主类 org.gradle.launcher.daemon.bootstrap.GradleDaemon”?的主要内容,如果未能解决你的问题,请参考以下文章

React Native Android - 无法找到或加载主类 org.gradle.wrapper.GradleWrapperMain

如何修复 npm 审计修复问题?

如何修复drv?

如何修复漏洞

如何修复WMI

PHP网站漏洞怎么修复 如何修补网站程序代码漏洞