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

不羁岁月 提交于 2019-11-27 01:02:47

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.

If you have limited internet plan then use the following method.

Step1: Close android studio

Step2: Go to C:\Users\Khurshid\.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo (if you want to configure gradle 1.12)

Step3: try to open the gradle-1.12-all.zip by double clicking it. If it gives error message then delete the zip file.

step4: go to https://services.gradle.org/distributions and download gradle-1.12-all.zip (54mb approx) and copy the same to the folder where you have previously deleted the zip file.

step5: open android studio and go to file->setting select 'gradle' and click on 'use local gradle distribution' and set 'gradle home' to 'C:\Users\Khurshid\.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo\gradle-1.12-all.zip' and click ok.

step6: It will download some file over the internet. If download doesn't start automatically then restart android studio.

step7: Be patience and let it download some important stuff and after that everything should be working fine. This method will help you save your internet data. Downloading the entire gradle directory will consume double the data.

Thank You

I also faced the similar issue when imported the existing project into Android Studio, this might happened because of gradle version mismatch between two different Android Studio platform.

Solution(on Mac OS):

  1. Close the Android Studio.
  2. Locate the .gradle folder at User/.gradle/
  3. Delete the folder & clear the Trash.
  4. Relaunch the Android Studio & Sync your project. It will re-download the gradle plugins & configurations.

For me the solution to this error was to change the gradle wrapper version in ../gradle/wraper/gradle-wrapper.properties to a different/newer version.. I used:

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

Then call:

./gradlew --refresh-dependencies

This tells the wrapper to point to a new version and re-download all required dependencies. I suspect the error for me was caused by an interrupted download when first building the relevant project.

I fixed this issue by...

  • Going to Settings... > Gradle
  • Selecting "Use local Gradle distribution."
  • Pointed it to my Gradle zip file: home/kersting/.gradle/wrapper/dists/gradle-1.12-all/6vpvhqu0efs1fqmqr2decq1v12/gradle-1.12

It should be something similar for you if you downloaded Gradle which you should have when you downloaded Android Studio. Be careful, the .gradle file may be hidden. I found it through the terminal, but "ls" didn't reveal it.

I had the same problem, happened after turning on and off jack and jill tool chain. I tried removing .gradle but it didn't help. Removing the build directory inside my project folder resolves the problem.

Try this before removing .gradle as it will need near 200MB worth of download.

I fixed the same issue via the following:

Go to File -> Settings -> Gradle

Input the following in the "Gradle VM options:" box: -XX:MaxHeapSize=256m -Xmx256m

Hit apply and Android Studio should build your project successfully.

Clearing .gradle directory didn't help, but clearing build directory did the job for me.

You just have to edit build.gradle file.

you should set the classpath to the latest gradle version

  dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}

and Sync the project. All errors will be gone. What you can do is, make new project in android studio, which will have classpath of latest gradle and paste it into your project that having Cause: error in opening zip file. this error.

I had the same problem so and to fix it i download the last version of gradle:

https://services.gradle.org/distributions

and open the gradle in the right bar then choose gradle parameters and change the path of the old gradle into the new one.

Deleting the .gradle folder worked for me. Problem resolved after I deleted .gradle folder

In recent versions of Android Studio File -> Invalidate Caches / Restart is worth trying.

Jesus Navas

I had the same issue

  • Go to C:\Users\Jesus Navas.gradle\wrapper\dists\gradle-3.3-all(your gradle version).

  • Erase your current gradle version and write again in cmd "ionic build android".

  • However, your gradle will download again, then it will unzip it automatically, ready checkout the output .apk,

this solved my issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!