如何清除gradle缓存? [英] How to clear gradle cache?

查看:557
本文介绍了如何清除gradle缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android Studio,并且第一次启动它时,编译需要 45 分钟...如果我不退出应用程序,也没关系 - 每次后续编译/运行应用大约需要 45 秒.

I'm trying to use Android Studio, and the first time I boot it up, it takes like 45 MINUTES to compile... If I don't quit the application, it is okay - each subsequent compilation/running the app will take around 45 seconds.

我试图检查我的一些缓存:我的主目录中有一个 .gradle/caches 文件夹,它包含 123 MB.

I've tried to check some of my caches: there's a .gradle/caches folder in my home directory, and it's contains 123 MB.

在我的项目文件夹中还有一个 .gradle 文件夹......其中一个 taskArtifacts 大约 200 MB.我害怕只是随机地对他们俩进行核弹.可以安全删除文件夹的哪些部分?

There's also a .gradle folder in my project folder... one of the taskArtifacts was like 200 MB. I'm scared to just randomly nuke them both. What parts of the folders are safe to delete?

有没有更好的解释为什么我的 Android Studio 在第一次加载应用程序时需要永远运行 gradle assemble 任务?

Is there a better explanation for why my Android Studio is taking forever to run the gradle assemble task upon first time loading the application?

我是否也必须清除 Intellij 缓存?

Do I also have to clear the intellij cache too?

推荐答案

正如@Bradford20000 在评论中指出的,可能有一个 gradle.properties 文件以及位于 <代码>$HOME/.gradle.在这种情况下,删除该目录的内容时要特别注意.

As @Bradford20000 pointed out in the comments, there might be a gradle.properties file as well as global gradle scripts located under $HOME/.gradle. In such case special attention must be paid when deleting the content of this directory.

.gradle/caches 目录包含 Gradle 构建缓存.因此,如果您对构建缓存有任何错误,可以将其删除.

The .gradle/caches directory holds the Gradle build cache. So if you have any error about build cache, you can delete it.

--no-build-cache 选项将在没有构建缓存的情况下运行 gradle.

The --no-build-cache option will run gradle without the build cache.

MS Windows 上的守护程序如果您使用的是 Windows,则需要先终止守护程序,然后才能清除这些目录.有关详细信息,请参阅杀死所有 Gradle 守护进程,无论版本?.

Daemon on MS Windows If you're on Windows, you'll need to kill the daemon before it allows you to clear those directories. See Kill all Gradle Daemons Regardless Version? for more info.

这篇关于如何清除gradle缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆