安卓工作室Gradle构建失败

6
我最近几天一直在面临这个问题。当我尝试构建项目时,Gradle会抛出以下错误信息。我已经清理了项目并重新下载了依赖项,但问题仍未得到解决。
请帮助我找到解决方案。
错误信息:
:app:dexDebug
Error:org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$FileCollectionSnapshotImpl cannot be cast to org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter$OutputFilesSnapshot
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

尝试删除Gradle缓存文件夹:在Windows上为C:\ Users \<username> \ .gradle \ cache,在Linux / Mac上为〜/ .gradle / cache - rciovati
使用命令 ./gradle --stop 停止所有守护进程。你的项目是否使用 Gradle Wrapper?如果是,那么你不需要使用本地的 Gradle 安装,只需运行命令 ./gradlew build 即可。 - Blundell
作为新手,我实际上不理解你的回答。能否请您更具体一些,@RiccardoCiovati? - Aawaz Gyawali
1个回答

9

谢谢你的回复@Shawlaw。但是我早就解决了这个问题,甚至不记得我做了什么。我尝试了许多解决方案,也不知道哪一个起作用了。 - Aawaz Gyawali

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接