You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native项目Gradle构建报错:zip END header not found

React Native Gradle构建错误:zip END header not found 解决建议

我在开发React Native项目时遇到Gradle构建失败,错误栈如下:

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

我已尝试若干解决方法但问题仍未解决,以下是其他开发者总结的可行解决建议:

  • 清理Gradle缓存并刷新依赖
    执行命令清理项目构建缓存并强制重新下载依赖:

    ./gradlew clean
    ./gradlew build --refresh-dependencies
    

    同时手动删除本地全局Gradle缓存目录,彻底清理损坏的缓存文件:

    • Windows:C:\Users\<你的用户名>\.gradle\caches
    • macOS/Linux:~/.gradle/caches
  • 删除损坏的本地依赖并重新安装
    错误提示zip文件损坏,大概率是下载的依赖包不完整。删除项目本地的依赖缓存和构建目录后重新安装:

    rm -rf node_modules android/build android/app/build
    npm install
    
  • 匹配Kotlin与React Native的版本兼容性
    错误涉及Kotlin的BuildFlowService,需确保项目中Kotlin Gradle插件版本与当前React Native版本兼容。在android/build.gradle中指定对应版本:

    buildscript {
        ext {
            kotlinVersion = "1.8.22" // 请根据你的React Native版本调整,可查看RN官方文档确认
        }
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        }
    }
    
  • 切换至稳定版Gradle分发包
    尝试更换Gradle版本为官方稳定版,修改android/gradle/wrapper/gradle-wrapper.properties中的distributionUrl:

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

内容的提问来源于stack exchange,提问作者Irfanali Saiyad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 13:31:01