本文介绍了如何手动设置gradle-2.2.1-all.zip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用这个命令运行我的单元测试。

  gradlew.bat connectedInstrumentTest 

但它会尝试下载



我的下士网络阻止它。因此,我想手动设置zip文件,我已经从浏览器中下载了它。



我列出的失败方式如下:
$ b $在程序文件中粘贴它\Android\Android Studio\gradle\
gradle-2.2.1无法正常工作

  • li>文件 - >设置 - >构建执行,部署 - >构建工具和定义gradle主目录的
    不起作用


    任何建议,除了这些将不胜感激。感谢。

    解决方案

    在您的命令中使用。 Gradle包装是真正的Gradle bin周围的薄包装。它的目的是检入您的源代码控制,然后下载您在 gradle / wrapper / gradle-wrapper.properties 中定义的Gradle版本。这里的优点是构建中使用的Gradle版本直接绑定到源代码管理。



    您有2个选项:


    • 使用 gradle 命令而不是 gradlew - 这将使用 gradle 安装在本地计算机上(假设'gradle'在PATH上)。这里的缺点是你必须在生成之前将Gradle安装在某处。
    • 中更改 distributionUrl >
    • gradle / wrapper / gradle-wrapper.properties 指向一个不同的URL和主机,它自己在某处。您可以获得包装的所有优点,但可以解决下载问题。


    I want to run my unit test with this command

    gradlew.bat connectedInstrumentTest
    

    But it tries to download https://services.gradle.org/distributions/gradle-2.2.1-all.zip

    And my corporal network blocks it. Hence, I want to setup the zip manually, I already downloaded it from browser.

    The ways I failed are listed below

    • Pasting it in Program Files\Android\Android Studio\gradle\gradle-2.2.1 didn't work
    • File -> Settings -> Build execution, Deployment -> Build Tools anddefining the gradle home directory didn't work

    Any suggestions except these will be much appreciated. Thanks.

    解决方案

    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.

    You have 2 options:

    • use the gradle command instead of gradlew - this will use the gradle 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 in gradle/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 10-23 16:01