How to Setup gradle-2.2.1-all.zip Manually
Asked Answered
R

3

9

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 and defining the gradle home directory didn't work

Any suggestions except these will be much appreciated. Thanks.

Rockribbed answered 14/7, 2015 at 11:58 Comment(2)
The network blocked the script from downloading the zip file, but you were able to do so successfully?Immense
have you checked Offline work in Global Gradle setting?Precocity
Z
8

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.
Zygophyllaceous answered 14/7, 2015 at 12:27 Comment(1)
This works! If you have a Samba/FS host, you could change it to something like: distributionUrl=file:///user/me/downloads/gradle.zipTruckle
A
9

Solution :

1). Delete the C:\Users\username\.gradle folder

2). Download http://downloads.gradle.org/distributions/gradle-2.2.1-all.zip

3). Create a new project in android studio.

4). When this time it stucks at gradle building, Force close the android studio.

5) Now go to C:\Users\username\.gradle\wrapper\dists\gradle-2.2.1-all\c64ydeuardnfqctvr1gm30w53 (the end directory name may be different)

6) Delete gradle-2.2.1-all.zip.lck and other files from this directory.

7) Paste the new downloaded gradle-2.2.1-all.zip here.

8) Run the android studio. :)

Antonio answered 24/9, 2015 at 10:49 Comment(1)
I havn't Dist folder after the path C:\Users\username\.gradle\wrapper\Providenciaprovident
Z
8

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.
Zygophyllaceous answered 14/7, 2015 at 12:27 Comment(1)
This works! If you have a Samba/FS host, you could change it to something like: distributionUrl=file:///user/me/downloads/gradle.zipTruckle
S
0

Mostly, this error occurs due to brake in internet or slow connection network. A gradle file downloads partially, this zip file isn't extractable and neither does re-download using Android Studio work.

So, to solve this problem, you have to:

  1. Delete the gradle download folder or download the gradle zip file manually and configure using the following method
  2. Download requires gradle and past the zip into C:\Users\your_pc_name\.gradle\wrapper\dists
  3. Finally, open Android Studio and run the project.

The gradle version care fully before downloading

Gradle name

Sloan answered 17/8, 2020 at 6:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.