前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >React Native 运行报错 error in opening zip file

React Native 运行报错 error in opening zip file

作者头像
草帽lufei
发布2022-07-29 09:35:27
5890
发布2022-07-29 09:35:27
举报
文章被收录于专栏:程序语言交流程序语言交流

基于 React Native 中文网教程 编译并运行 React Native 应用

在项目 (AwesomeProject) 根目录下运行命令 yarn rect-native run-androidyarn android 出现如下错误

代码语言:javascript
复制
D:\code\AwesomeProject> yarn react-native run-android
PS D:\code\AwesomeProject> yarn rect-native run-android
yarn run v1.22.11
error Command "rect-native" not found. Did you mean "react-native"?
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS D:\code\AwesomeProject> yarn react-native run-android
yarn run v1.22.11
$ D:\code\AwesomeProject\node_modules\.bin\react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 870 file(s) to forward-jetify. Using 16 workers...
info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Could not unzip C:\Users\w\.gradle\wrapper\dists\gradle-6.9-all\dooywd8nv05k16orzxge2b1bs\gradle-6.9-all.zip to C:\Users\w\.gradle\wrapper\dists\gradle-6.9-all\dooywd8nv05k16orzxge2b1bs.
Reason: error in opening zip file
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:228)
        at java.util.zip.ZipFile.<init>(ZipFile.java:157)
        at java.util.zip.ZipFile.<init>(ZipFile.java:171)
        at org.gradle.wrapper.Install.unzip(Install.java:239)
        at org.gradle.wrapper.Install.access$900(Install.java:27)
        at org.gradle.wrapper.Install$1.call(Install.java:81)
        at org.gradle.wrapper.Install$1.call(Install.java:48)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:228)
        at java.util.zip.ZipFile.<init>(ZipFile.java:157)
        at java.util.zip.ZipFile.<init>(ZipFile.java:171)
        at org.gradle.wrapper.Install.unzip(Install.java:239)
        at org.gradle.wrapper.Install.access$900(Install.java:27)
        at org.gradle.wrapper.Install$1.call(Install.java:81)
        at org.gradle.wrapper.Install$1.call(Install.java:48)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

    at makeError (D:\code\AwesomeProject\node_modules\execa\index.js:174:9)
    at D:\code\AwesomeProject\node_modules\execa\index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async runOnAllDevices (D:\code\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5)
    at async Command.handleAction (D:\code\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

报错提示没有正确安装 Android 开发环境,以及文件打开错误

代码语言:javascript
复制
Could not unzip C:\Users\w\.gradle\wrapper\dists\gradle-6.9-all\dooywd8nv05k16orzxge2b1bs\gradle-6.9-all.zip to C:\Users\w\.gradle\wrapper\dists\gradle-6.9-all\dooywd8nv05k16orzxge2b1bs.
Reason: error in opening zip file
Exception in thread "main" java.util.zip.ZipException: error in opening zip file


error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
解决方式

在文件资源管理器中找到 C:\Users\w\.gradle\wrapper\dists 目录,删除里面的 gradle-6.9-all.zip 文件, 重新运行 yarn android 命令重新安装 Android 相关环境就好了

版本信息
  • 系统:Windows 11
  • React Native: 0.66
  • Java: 1.8.0_312
  • Javac: 1.8.0_312
本文参与?腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-11-03,如有侵权请联系?cloudcommunity@tencent.com 删除

本文分享自 参谋总长萨博 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 解决方式
  • 版本信息
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com