Sunday, July 20, 2025

How to Resolve 'Exception in thread "main" java.util.zip.ZipException: zip END header not found' in Flutter 3.29.2

authorImage

Haider Naqvi

postMainImage

The "Zip and header not found" error occurs when the Gradle wrapper fails to read or parse a zip file, especially a Gradle distribution package. This can be caused by a corrupted or incomplete download (often due to network issues), conflicts accepting file access, or an incorrect complete version specified in gradle-wrapper.properties. This error can also be caused by corrupt files in ~/.gradle/dists or an unsupported Java version. Basically, the build system expects a properly wrapped zip archive but a part of it is broken or prevents it from executing properly. Resolving this usually involves clearing corrupt caches or ensuring a usable setup.

Now that we have narrowed down the root cause of the “Zip and header not found” error in Flutter3.29.2, let’s dive into the solutions. Here is some good news for you friends. It can be resolved in a few steps. Due to the issues and unpopular Java version.

Let’s proceed step by step to resolve this sound. To update the selected version to a clean version then do the cache and rollback.

  • Update the Gradle distribution URL

The first and easiest solution is to edit your Gradle wrapper properties file:

Go to:

android/gradle/wrapper/gradle-wrapper.properties

android/gradle/wrapper/gradle-wrapper.properties

Locate the distributionUrl line (it usually looks like this):

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

Change it to use the stable base version (remove the patch number):

gradle-8.10-all.zip

Why this works:

Flutter 3.29.2 may not work with certain Gradle patch versions (8.10.2, for instance). Because the base version (8.10) is more extensively tested, it frequently fixes extraction errors.

Note:

Always verify the Gradle version available on the official Gradle distribution page before making changes.

  • Update Android plugin and Kotlin version.

If you changed the Gradle URL, the next step is to adjust the plugin versions in your android/Settings.Gradle.kits file. Here’s how:

Go to:

android/settings.gradle.kts

Locate the plugin block (it should look similar to this):

plugin block

plugins {

id("dev.flutter.flutter-plugin-loader") version "1.0.0"

id("com.android.application") version "8.7.0" apply false

id("org.jetbrains.kotlin.android") version "1.8.22" apply false

}

Update the versions:

Change com.android.application from 8.7.0 → 8.3.2

Change org.jetbrains.kotlin.android from 1.8.22 → 1.9.24

Now the updated block should look like this.

updated plugin block

plugins {

id("dev.flutter.flutter-plugin-loader") version "1.0.0"

id("com.android.application") version "8.3.2" apply false

id("org.jetbrains.kotlin.android") version "1.9.24" apply false

}

Why This Works

While 8.3.2 is more stable, Android Gradle Plugin 8.7.0 has problems with Flutter 3.29.2.

Kotlin 1.9.24 eliminates build conflicts and is optimized for the most recent Gradle versions.

  • Last Actions

Use these commands to reset and rebuild your project after saving the changes:

flutter clean

flutter pub get

flutter run

The outcome: The zip END header error should no longer occur when your project compiles. Go to Step 3 (clearing the Gradle cache) if the problems continue.

Enjoyed this article?

Leave a Comment below!