java 无法打开 .zip Gradle Cache 可能已损坏错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42622780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to open .zip Gradle Cache May be corrupt error
提问by Zaigham Raza
I am facing Gradle cache error and I don't know how to tackle it. I have attached the error snap with my question below. I tried different solutions posted at stack-overflow but none of them worked. Anyone suggest me a solution Any additional suggestions would be helpful.
我正面临 Gradle 缓存错误,我不知道如何解决它。我在下面的问题中附上了错误快照。我尝试了在 stack-overflow 上发布的不同解决方案,但都没有奏效。任何人都向我建议解决方案任何其他建议都会有所帮助。
e.g Error: Failed to open zip file.e.g Error: Failed to open zip file.
例如错误:无法打开 zip 文件。例如错误:无法 打开 zip 文件。
采纳答案by Zaigham Raza
- Download the latest gradle package from this directory
- Extract it and put it somewhere (for example f:\gradle-1.10)
- Go to your Android Studio and load your project then open File->Settings->gradle, in this page click on Use local gradle distribution.
- Type your gradle folder address there.
- 从这个目录下载最新的gradle包
- 提取它并把它放在某个地方(例如 f:\gradle-1.10)
- 转到您的 Android Studio 并加载您的项目,然后打开 File->Settings->gradle,在此页面中单击 Use local gradle distribution。
- 在那里输入你的 gradle 文件夹地址。
回答by Adil Raza Bangash
Its because your gradle directory is not the directory of your gradle, to check go to android studio open your project then open File->Settings->Build,Execution, Deployment->Gradle
这是因为你的 gradle 目录不是你的 gradle 目录,要检查去 android studio 打开你的项目然后打开 File->Settings->Build,Execution, Deployment->Gradle
回答by Solanki Mimoh
Hey not necessary to set gradle manually. i have also faced this issue but i deleted all files in gradle folder path "C:/Users/username/.gradle/" simple steps follow
嘿不需要手动设置gradle。我也遇到过这个问题,但我删除了 gradle 文件夹路径“C:/Users/username/.gradle/”中的所有文件,遵循简单的步骤
- first goto path "C:/Users/username/.gradle/"
- delete all files in above path.
- open android studio and sync gradle or build again or create new project.
- it will be auto downloaded new gradle version files and auto build.
- 首先转到路径“C:/Users/username/.gradle/”
- 删除上述路径中的所有文件。
- 打开android studio并同步gradle或再次构建或创建新项目。
- 它将自动下载新的 gradle 版本文件和自动构建。
*Make sure you your gradle settings like this- checked "Use default gradle wrapper(recommended) - unchecked offline work
*确保你的 gradle 设置是这样的- 选中“使用默认的 gradle 包装器(推荐) - 未选中的离线工作
回答by Md Imran Choudhury
You can download manually but this is another solution: Change "https" to "http"on 'gradle-wrapper.properties' in root project.
您可以手动下载,但这是另一种解决方案:在根项目中将“ gradle-wrapper.properties ”上的“https”更改为“http”。
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
to,
distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-all.zip
回答by Elyran
If you want to use gradle wrapper - delete anything under:
如果您想使用 gradle 包装器 - 删除以下任何内容:
.gradle/wrapper/dists/
and refresh gradle. The gradle wrapper will download from scratch and everything should work fine.
并刷新gradle。gradle 包装器将从头开始下载,一切正常。
回答by kan137g
- first :i tried to delete the .gradle folder from project it doesn't work;
- second: i tried use the old version gradle ,but studio force me to use gradle-3.3,so it confused me long time;
- third:I noticed the tips unzip exception"java.util.zip.ZipException: error in opening zip file", I tried to unzip the file by handset's really can't unzip, so the problem must happen in the download process.
- 首先:我试图从项目中删除 .gradle 文件夹,但它不起作用;
- 第二:我尝试使用旧版本的 gradle,但是工作室强迫我使用 gradle-3.3,所以它让我困惑了很长时间;
- 第三:我注意到解压异常提示“java.util.zip.ZipException: error in open zip file”,我尝试用手机解压文件确实解压不出来,应该是下载过程中出现的问题。
solution: I copy the file "gradle-3.3-all.zip " from my colleague who build success,and replace mine in such path ".gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all.zip "
解决方案:我从我构建成功的同事那里复制文件“gradle-3.3-all.zip”,并在这样的路径“.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all”中替换我的文件。压缩 ”
回答by SpkingR
I solved this problem with the installation of Gradle using HomeBrew on Mac. If you type gradle -v
in terminal and shows command not found: gradle
, then I think you can use this way to solve this problem on Mac:
我通过在 Mac 上使用 HomeBrew 安装 Gradle 解决了这个问题。如果你输入gradle -v
终端并显示command not found: gradle
,那么我认为你可以在Mac上使用这种方式解决这个问题:
First install the Gradle with Homebrew:
brew install gradle
Then go to Android Studio, open
Android Studio->Preferences->Build,Execution,Deployment->Gradle
, underProject-level settings
check:Use local gradle distribution
and set Gradle home with: '/usr/local/Cellar/gradle/3.5/libexec'(3.5 is my gradle version)Try again, and if the version is not correct, you can manually download the specified version from gradle website (the version specified in the file
<your project dir>/gradle/wrapper/gradle-wrapper.properties
:distributionUrl=<url>
), extract the downloaded zip file to the location and set the Gradle home to it in Android Studio.
首先使用 Homebrew 安装 Gradle:
brew install gradle
然后转到 Android Studio,打开
Android Studio->Preferences->Build,Execution,Deployment->Gradle
,在Project-level settings
check:下Use local gradle distribution
设置 Gradle home:'/usr /local/Cellar/gradle /3.5 /libexec '(3.5 是我的 gradle 版本)再试一次,如果版本不正确,您可以手动下载从gradle这个网站指定的版本(在文件中指定的版本
<your project dir>/gradle/wrapper/gradle-wrapper.properties
:distributionUrl=<url>
),解压下载的zip文件的位置,并设置摇篮回家给它Android Studio中。
Hope that helps.
希望有帮助。
回答by user1935005
From my MAC i just go to the gradle folder (/Users/USER/.gradle) > wrapper > dist and delete the gradle folder with the problem. Then go to studio and re-download the gradle file.
从我的 MAC 中,我只需转到 gradle 文件夹 (/Users/USER/.gradle) > wrapper > dist 并删除有问题的 gradle 文件夹。然后去studio重新下载gradle文件。