4

I updated my Android Studio from 2.2.3 to 2.3. Since then I am getting this

Error:

Failed to open zip file. 
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) 
<a href="syncProject">Re-download dependencies and sync project (requires network)</a> 
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
.....

I am unable to find a solution for it despite searching again & again

PravinS
  • 2,640
  • 3
  • 21
  • 25
Sameet Raza
  • 51
  • 1
  • 1
  • 4
  • 1
    "Since that I am getting this error" When is this error occurring? Opening Android Studio? Opening a project? Building a project? Did you try doing what the message suggests? – HPierce Mar 05 '17 at 17:07
  • Whenever I try to Run the Main Activity I get this error..... Also when I try to do as the message suggests the program Re-runs and displays the same message again... – Sameet Raza Mar 06 '17 at 06:35

2 Answers2

8

This problem arises when android studio is not able to access the gradle.zip file. The easiest way to resolve this is to follow what studio tells you to do, in this case it says to re-download the dependencies. Due to a very minor glitch this doesn't work.

In order to solve it:

  1. Go to gradle-wrapper.properties from the "project" side menu
  2. Then change:

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip to distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

After this studio should be able to download the correct zip file i.e. "gradle-3.3-all.zip"

If this does not help then you will have to make a few efforts.

  1. Download the zip file manually from gradle-3.3-all.zip
  2. Copy the zip file.
  3. Reach the directory wherever your ".gradle" folder exists(It's usually in "C:\Users\user.gradle", if you are on windows).
  4. Then navigate to "wrapper" and then to "gradle-3.3-all".
  5. Replace the zip file already there with the newly downloaded zip file.

"Replace being the keyword here."

Sync your project. It may take time to sync, but it will definitely sync. It solved the problem for me. Cheers!!

maverick6912
  • 108
  • 1
  • 10
3

on your MAC just run below command & sync again

rm -Rf ~/.gradle
Virender
  • 168
  • 10