Search code examples
react-nativegradleandroid-gradle-pluginbuild.gradlegradle-plugin

Gradle Build Error: "zip END header not found" in React Native Project


I'm encountering a Gradle build error while working on my React Native project. The error message is:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'.

java.io.UncheckedIOException: java.util.zip.ZipException: zip END header not found

java.util.zip.ZipException: zip END header not found

org.gradle.internal.snapshot.impl.IsolationException: Could not isolate value 

org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@dff515a of type BuildFlowService.Parameters

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'.

java.io.UncheckedIOException: java.util.zip.ZipException: zip END header not found

java.util.zip.ZipException: zip END header not found

Despite these attempts, the issue persists. Has anyone faced a similar issue? Any suggestions on how to fix this?


Solution

  • This issue happens because of Kotlin version 1.9.24.

    There are two solutions for this.

    First solution

    Upgrade React Native to version 0.77, as it depends on Kotlin 2.x ( which is not affected )


    Second solution

    Use patch-package to update the Kotlin version here node_modules/@react-native/gradle-plugin/gradle/libs.versions.toml, change kotlin = "1.9.24" to kotlin = "1.9.25"

    [versions]
    agp = "8.5.0"
    gson = "2.8.9"
    guava = "31.0.1-jre"
    javapoet = "1.13.0"
    junit = "4.13.2"
    kotlin = "1.9.25"
    assertj = "3.25.1"
    

    To set a package-patch, you can check this video

    Source