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

Windows环境下运行npx expo run:android遇ZipException报错求助

解决Windows下npx expo run:android触发java.util.zip.ZipException的方法

这个错误本质是Gradle下载的react-native-gradle-plugin相关依赖包损坏,导致解压时找不到zip结束头,以下是针对性解决步骤:

  • 清理Android Studio缓存与损坏的依赖包

    1. 删除C:\Users\<你的用户名>\.android\cache目录下所有内容
    2. 找到C:\Users\<你的用户名>\.gradle\caches\modules-2\files-2.1\com.facebook.react,删除其中和react-native-gradle-plugin相关的所有文件夹及文件
  • 强制Gradle重新拉取依赖
    在项目根目录打开命令行,依次执行:

    gradlew cleanBuildCache
    gradlew build --refresh-dependencies
    
  • 指定稳定的插件与Gradle版本

    1. 打开项目android/build.gradle,找到dependencies块里的classpath("com.facebook.react:react-native-gradle-plugin"),手动指定匹配你RN版本的稳定号,比如RN0.72对应:
      classpath("com.facebook.react:react-native-gradle-plugin:0.72.0")
      
    2. 检查gradle/wrapper/gradle-wrapper.properties里的distributionUrl,确保Gradle版本和插件兼容,比如RN0.72推荐用https\://services.gradle.org/distributions/gradle-7.5-all.zip
  • 禁用Gradle离线模式

    1. 打开Android Studio,进入Settings -> Build, Execution, Deployment -> Build Tools -> Gradle,取消勾选"Offline work"
    2. 或者直接用命令行临时禁用:
      gradlew --no-offline run:android
      
  • 排查网络环境
    如果使用了代理,检查代理配置是否正常,避免下载的包不完整;也可以切换到稳定的直连网络重新尝试构建

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 14:16:04