问题描述
为什么每次尝试导入新项目时,Android Studio 都会下载 gradle?
Why does Android Studio download gradle every time I try to import a new project?
最初,我导入了一个自动下载 Gradle 2.1 的 gradle 项目.随后,为了第二个项目导入,它下载了 Gradle 1.10.现在再次导入第三个项目时,它已经下载了 Gradle 2.2.1.
Initially, I imported one gradle project for which Gradle 2.1 was auto-downloaded. Subsequently, for a second project import, it downloaded Gradle 1.10. Now again while importing a third project, it has downloaded Gradle 2.2.1.
发生了什么?
推荐答案
项目可以声明他们需要运行哪个 Gradle(参见 gradle
目录中的 gradle.properties
文件项目的根目录).
Projects can declare which Gradle they require to run (see gradle.properties
file in gradle
directory in the root of the project).
Android Studio 使用此信息下载并运行正确的版本(它实际上不是 Android Studio,而是 Gradle Wrapper 在其中运行).这是一件好事.
Android Studio uses this information to download and run the right version (it's actually not Android Studio, it's the Gradle Wrapper running inside it). And it's a good thing.
你能做什么?
- 等等.在
~/.gradle
目录中下载版本后,它将用于声明相同版本的任何项目.这是一次性缓存. - 在导入项目时禁用包装器的使用.我真的不建议这样做!因此,您的项目可能无法构建.
- Wait. Once you have the version downloaded in
~/.gradle
directory, it will be used for any project declaring the same version. It's one-time cache. - Disable the usage of the wrapper when you import the project. I really recommend against it! You project might not build because of that.
这篇关于为什么每次导入一个新的 gradle 项目时,Android Studio 都会下载 gradle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!