问题描述
我想用这个命令运行我的单元测试
I want to run my unit test with this command
gradlew.bat connectedInstrumentTest
但它试图下载 https://services.gradle.org/distributions/gradle-2.2.1-all.zip
我的下士网络阻止了它.因此,我想手动设置 zip,我已经从浏览器下载了它.
And my corporal network blocks it. Hence, I want to setup the zip manually, I already downloaded it from browser.
我失败的方法如下
- 粘贴到 Program Files\Android\Android Studio\gradle\gradle-2.2.1 没用
- File -> Settings -> Build execution, Deployment -> Build Tools and定义 gradle 主目录不起作用
除这些之外的任何建议将不胜感激.谢谢.
Any suggestions except these will be much appreciated. Thanks.
推荐答案
在您的命令中,您正在使用 Gradle包装.Gradle 包装器是围绕真正的 Gradle 箱的薄包装器.它旨在签入您的源代码管理,然后下载您在 gradle/wrapper/gradle-wrapper.properties
中定义的 Gradle 版本.这里的优点是构建中使用的 Gradle 版本直接绑定到源代码管理.
In your command you're using the Gradle Wrapper. The Gradle wrapper is a thin wrapper around the real Gradle bin. It's intended to be checked in to your source control and it then downloads the version of Gradle you've defined in gradle/wrapper/gradle-wrapper.properties
. The advantage here is the version of Gradle used in the build is directly tied to the source control.
您有两个选择:
- 使用
gradle
命令而不是gradlew
- 这将使用安装在本地机器上的gradle
(假设 'gradle' 是在路径上).这里的缺点是您必须在构建工作之前在某处安装 Gradle. - 更改
gradle/wrapper/gradle-wrapper.properties
中的distributionUrl
以指向不同的 URL 并将该文件自己托管在某个地方.您可以获得包装器的所有优点,但可以解决下载时遇到的问题.
- use the
gradle
command instead ofgradlew
- this will use thegradle
that's installed on the local machine (assumes that 'gradle' is on the PATH). The drawback here is you have to have installed Gradle somewhere before the build will work. - change
distributionUrl
ingradle/wrapper/gradle-wrapper.properties
to point to a different URL and host that file yourself somewhere. You get all the advantages of the wrapper but fix the problems you're having downloading it.
这篇关于如何手动设置 gradle-2.2.1-all.zip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!