Error:Failed to open zip file. Gradle's dependency cache may be corrupt

Reem Aziz picture Reem Aziz · Mar 7, 2017 · Viewed 176.1k times · Source

I updated android studio 2.3 and there is a bug, gradle doesn't build and it keeps giving me the same error for all projects.

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 have already searched for a solution, but have not found any. I tried:

Invalidate Caches / Restart...

but nothing has changed.

Answer

Hamid Asghari picture Hamid Asghari · May 5, 2017

Repair Gradle Installation

This usually happens when something goes wrong in Android Studio's first launch (eg. system crash, connection loss or whatever).

To resolve this issue close Android Studio and delete the following directory's content, necessary files will be downloaded on IDE's next launch.

macOS: ~/.gradle/wrapper/dists

Linux: ~/.gradle/wrapper/dists

Windows: C:\Users\your-username\.gradle\wrapper\dists

While downloading Gradle manually works, I recommend letting Android Studio itself to do it.