flutterandroid-studiogradleexception

Exception in thread "main" java.util.zip.ZipException: zip END header not found


I get such error while run a project in flutter. Why is this happening and how can I fix this error?

Exception in thread "main" java.util.zip.ZipException: zip END header not found
    at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1581)
    at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1476)
    at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1483)
    at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1288)
    at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1251)
    at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:732)
    at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:849)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:247)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:177)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:191)
    at org.gradle.wrapper.Install.unzip(Install.java:214)
    at org.gradle.wrapper.Install.access$600(Install.java:27)
    at org.gradle.wrapper.Install$1.call(Install.java:74)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception: Gradle task assembleDebug failed with exit code 1

Solution

  • Why is this happening?

    => The error is related to Gradle, it is usually caused by a corrupt or incomplete Gradle setup

    how to fix this error?

    For mac user: open terminal and execute

    cd ~

    rm -rf .gradle

    For windows user:

    Go to the root directory C:\Users\YourUser and locate the hidden .gradle folder and delete it. and then run your app connected to an Android emulator or device, don't cancel and make have a stable internet connection, this will download fresh Gradle