1

enter image description hereI installed android studio 3.2.1 and tried to create a simple hello world app. But don't know why it gives error:

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

Though I have a proper internet connection.

codeplay_
  • 31
  • 4
  • Try Open File > Sync project with Gradle files. or File > Invalidate/caches restart, – Khaled Lela Nov 03 '18 at 19:45
  • 3
    Possible duplicate of [Error:Failed to open zip file. Gradle's dependency cache may be corrupt](https://stackoverflow.com/questions/42652980/errorfailed-to-open-zip-file-gradles-dependency-cache-may-be-corrupt) – shashank chandak Nov 03 '18 at 19:46

3 Answers3

3

Try this solutions:

  1. File > Invalidate Caches / Restart...
  2. Build > Clean Project then Run
  3. gradlew build --refresh-dependencies
  4. Close Android Studio => Remove gradle caches folder => Open Android Studio then gradle will try to download and fix dependencies.

    • For Windows: open this path and delete caches folder.

      C:\Users\[username]\.gradle\caches
      
    • For Unix systems:

      rm -rf $HOME/.gradle/caches/
      
Khaled Lela
  • 5,495
  • 5
  • 39
  • 63
2

codeplay, first off I'd like to say welcome to stack overflow! I firmly believe that people who take the time to ask good questions on this site really go places in with their code. I got the same issue, and honestly can't remember exactly what I did to fix it, but I recommend looking at your SDK settings and reading up on gradle. It's time well spent https://developer.android.com/studio/build/

Bennington
  • 21
  • 4
0

I was facing the same issue. Few points you can verify :-

1.It may be your internet connection issue so check your internet connection is working well.

2.This can be solve by Perform invalidate cache/ Restart

3.If above 2 options are not wokring you need to reload the the dependencies so perform rm -rf $HOME/.gradle/caches/ and ./gradlew build --refresh-dependencies perfom these both commands and reverify your gradle path. This may solve your problem.