Android Studio - Failed to Complete Gradle Execution - Error in Opening Zip File

Android studio - Failed to complete gradle execution - error in opening zip file

An "error in opening zip file" tends to mean that a file that Gradle has downloaded has somehow become corrupted -- this might be the download of Gradle itself (which the wrapper does), or a dependency that Gradle has downloaded to run your build.

Gradle doesn't attempt to detect or resolve the problem, so you need to fix it manually. The solution is often to purge Gradle's download caches and let it get fresh copies of what it needs. To do that, delete the .gradle directories in both your home directory and in your project's root directory and try building again.

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

UPDATE 17 JULY 2018:

Even if the following solution still works as of today,I've found (thanks to the answer posted by Hamid Asghari and to the comment posted by Mahendra Dabi) that simply deleting the gradle dist directory and performing a reboot of the ide, will fix the issue (please read Hamid post for a full answer, and remember that OSX and Linux have the same gradle path).

If you still want to follow my original solution, you should at least consider using a more up-to-date version of Gradle (direct link of the gradle distribution repo: https://services.gradle.org/distributions/)


Original answer (dated 7 March 2017):

I've faced the same issue this morning after upgrading Android Studio to 2.3.
To solve the issue:

1) Manually download Gradle 3.3 binary (direct link: https://services.gradle.org/distributions/gradle-3.3-bin.zip)

2) Open your android studio root directory, and extract the zip to the gradle folder (for example in my Debian machine the full path is /opt/android-studio/gradle/gradle-3.3)

3) Open Android Studio, go to File->Settings->Build, Exectution, Deployment->Gradle and set "Gradle home" to point your new gradle-3.3 folder.

4) Sync and you are ready to go!

Android studio: error in opening zip files Gradle dependency cache may be corrupt

I switched my updates channel from stable to dev and Android Studio asked me to download updates which I did. Now the error is gone. I would really like to know what triggered that error. I wish the docs were more complete and include a section to ask this type of issues since this is not an issue caused by a developer's end.

Android Gradle produce a TransformException: java.util.zip.ZipException: error in opening zip file during transformClassesWithDexForRelease

If the error is not on the gradle zip but on a jar itself, make sure your compileSdkVersion, buildToolsVersion and targetSdkVersion are coherent.

If you still have the error, try building with a different version of the android gradle plugin, I was having a similar issue with com.android.tools.build:gradle:2.1.3 and it disappeared after upgrading to 2.2.0

Android Studio 2.3 for mac: gradle sync failed, error in opening zip file

Android Studio 2.3 requires:

  • Gradle plugin -at least- version 2.3.0

in the build.gradle file:

buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
  • And this plugin requires Gradle -at least- version 3.3

You can specify the Gradle version in either the File > Project
Structure > Project menu in Android Studio, or by editing the Gradle
distribution reference in the gradle/wrapper/gradle-wrapper.properties
file

in the gradle-wrapper.properties file:

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

More details


After making sure of all of above, if you still have problems in build try to clean Gradle cache folder and rebuild:

Open File then Settings Then Build, Execution and Deployment then Gradle and search for Service directory path this is the Gradle cache folder path.

Error:Failed to open zip file. Gradle dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

I faced the same issue when I updated my android studio to 2.2.3 from 2.1. After a while of struggling, went project->right click -> open module settings->project

1) Gradle : 2.14.1

2) Android plugin version : 2.2.3

3) Android plugin repository : jcenter

4) Default library repository : jcenter

Android Studio 0.8.7: Error:Cause: error in opening zip file

I changed the distributionUrl in the gradle-wrapper.properties file to the following (note the https instead of plain old http:

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

and it worked for me. I'd imagine this is a security issue... not sure what's preventing it though. Would still love if somebody had an explanation for why this is.



Related Topics



Leave a reply



Submit