skip to Main Content
Exception in thread "main" java.util.zip.ZipException: zip END header not found
    at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1474)
    at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1482)
    at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1320)
    at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1282)
    at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
    at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:186)
    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

This exception error is showing when the Flutter application is running.

2

Answers


  1. The Gradle task assembleDebug failed with exit code 1 error in Flutter can occur due to various reasons such as issues with AndroidX compatibility, incorrect Gradle version, network problems, or corrupted Gradle files. Here are several approaches to resolve the issue:

    1. Ensure AndroidX Compatibility: If your project uses Firebase plugins
      that require AndroidX, ensure your project is migrated to AndroidX.
      Update gradle.properties with the following lines:

      android.useAndroidX=true

      android.enableJetifier=true

    Then, refactor your project to AndroidX through Android Studio

    1. Upgrade Flutter Packages: Sometimes, simply upgrading the Flutter
      packages can solve the problem. Run:

      flutter pub upgrade

    2. Update Gradle Version: Check the gradle-wrapper.properties file and
      ensure the distribution URL points to the correct Gradle version.
      Also, verify that the build.gradle file specifies the correct Gradle
      plugin version

    3. Clean Project and Clear Cache: Delete .gradle and .m2 directories
      from your home directory and within your project. Then, run the
      following commands:

      flutter doctor

      flutter clean

      flutter packages pub cache clean

    4. Check Network Conditions: Ensure you have a stable internet
      connection since Gradle needs to download dependencies during the
      build process

    5. Avoid Special Characters in Path: If your project path contains
      special characters, it may cause issues. Move your project to a path
      without special characters.

    6. Correct Android Home Path: Ensure that the ANDROID_HOME environment
      variable is set correctly on Windows. An incorrect path can lead to
      build failures.

    7. Review Verbose Logs: Run flutter run –verbose to get detailed logs
      that can help identify the specific cause of the failure.

    8. Invalidate Caches in Android Studio: Go to File > Invalidate Caches
      / Restart
      … in Android Studio to clear the IDE’s internal cache,
      which might be causing issues.

    Try these solutions one by one, checking if the error is resolved after each step. If none of these solutions works, consider providing the verbose logs (flutter run –verbose) for further analysis.

    Login or Signup to reply.
  2. The error you’re encountering seems to be related to an issue with Gradle’s dependency resolution or corruption of the Gradle wrapper’s distribution file.

    Delete the gradle folder in your Flutter project directory
    
    flutter clean
    flutter pub cache repair
    
    

    upgrade flutter

    flutter upgrade
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search