一、报错日志
Unable to load class 'org.gradle.initialization.BuildCompletionListener'
org.gradle.initialization.BuildCompletionListener
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
二、分析报错
首先,看到当前项目使用的是gradle-8.5-bin。
然后,看到Java版本是默认的17。
但是,gradle插件版本居然是3.6.1。很明显gradle版本、插件版本和Java版本不一致,导致上述报错。
三、解决报错
1、Gradle工具使用的Java版本改为JDK1.8,然后Apply和OK。
2、修改gradle版本为5.6.4,适配gradle插件版本3.6.1。
#Mon Dec 02 16:08:12 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://mirrors.cloud.tencent.com/gradle//gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3、再次Sync就可以看到项目在下载依赖了。
我强烈推荐4本可以改变命运的经典著作: