Error:Failed to open zip file.Gradle's dependency cache may be corrupt 【Mac系統 AS】


轉載請註明出處:http://blog.csdn.net/yudbl/article/details/78581508


To take advantage of all the latest features (such as Instant Run), improvements and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.0.0 and Gradle to version 4.1.  You can learn more about this version of the plugin from the release notes.



最近手“不聽使喚”,AS提示更新就點啦,結果等了好久,因公司的網不敢恭維就斷開了,後來重新開啓項目工程時,出現如下提示:

Error:Failed to open zip file. 

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)

Re-download dependencies and sync project (requires network)


估計是文件沒更新完或損壞的原因


實踐解決方式:

方式1:

(1) AS項目中找到文件:build.gradle(Project: xx項目名)

把以前項目的classpath複製過來


(2)AS項目中找到文件:gradle-wrapper.properties

把以前項目的 distributionUrl複製過來




方式2:

因爲我有強迫症,既然更新了,我就想用最新的版本,於是嘗試成功了此種方式。

AS的菜單欄,點擊Android Studio,Preferences, Grade




搜索找到Gradle,點擊標註的圖標【或 複製路徑“/Users/luminal/.gradle”,回到桌面 command+shift +G搜索找到】




把目錄下最近更新的gradle刪除




AS項目中找到文件:gradle-wrapper.properties,

拷貝鏈接放瀏覽器上:services.gradle.org/distributions/gradle-4.1-all.zip 

即可下載,當然你也可以去網絡上搜索下載。下載其他版本更改版本號就行啦,

如:services.gradle.org/distributions/gradle-3.3-all.zip

把下載下來的zip包,拷貝到如上圖wrapper/dists 目錄下

然後重啓AS,AS會自己解壓刷新等,就OK啦(建議還是選擇網絡好點的地方)





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章