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

后端 未结 15 2111
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 04:21

I\'m new to android development and android studio IDE.

I\'ve checked-out a project from bitbucket and when I try to compile it I get the following error:

相关标签:
15条回答
  • 2020-11-29 04:26

    One of the causes of this problem (since late 2019) is the decommissioning of HTTP services by Gradle - and I see you are using HTTP protocol in your distributionUrl. This means that if your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file has an entry like:

    distributionUrl=http\://services.gradle.org/distributions/gradle-{version}.zip
    

    ... then this entry will try to retrieve a ZIP file from a service no longer servicing it (http based one) and it will silently return an empty ZIP file; which consequentially will be the source of an error from any process trying to unzip that empty ZIP file.

    To fix this, just change your [PROJECT_PATH]/gradle/wrapper/gradle-wrapper.properties file to have its distributionUrl entry to use https:

    distributionUrl=https\://services.gradle.org/distributions/gradle-{version}.zip
    

    Hope this helps.

    0 讨论(0)
  • 2020-11-29 04:27

    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.

    0 讨论(0)
  • 2020-11-29 04:27

    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.

    0 讨论(0)
  • 2020-11-29 04:27

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

    0 讨论(0)
  • 2020-11-29 04:30

    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

    0 讨论(0)
  • 2020-11-29 04:31

    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.

    0 讨论(0)
提交回复
热议问题