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
What Is the Simplest Way to Reverse an Arraylist
How to Create Thumbnail of Video Url Form Server
Android (Java) Simple Send and Receive with Server - Fast Setup Challenge
Spannable on Android for Textview
How to Read Data from Xls (Excel) File [Java, Android]
Install Xlsx and Rjava on MACos Mavericks 10.9.5
How to Do a Cross Platform Encryption Method Working in Both iOS and Android (Aes Encryption Only..)
Passing a String by Reference in Java
How to Generate Multiple Lines in PDF Using Apache PDFbox
How to Activate "Share" Button in Android App
Convert a String to a Byte Array and Then Back to the Original String
Why Can't I Use Resources.Getsystem() Without a Runtime Error
How to Wait for All Tasks in an Threadpoolexecutor to Finish Without Shutting Down the Executor
How to Launch Home Screen Programmatically in Android
How to Ask Permission to Access Gallery on Android M.
Simple Program to Call R from Java Using Eclipse and Rserve
What Is the Equivalent of a Java Hashmap<String,Integer> in Swift