下載了最新的AS,從倉庫拉了一個(gè)一年前的項(xiàng)目,在構(gòu)建時(shí)發(fā)生如下錯(cuò)誤提示:
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)
解決辦法
- 直接刪除 C:\Users\(用戶家目錄)\ .gradle\wrapper\dists
gradle-(對(duì)應(yīng)版本)-all 這個(gè)目錄。我這里是使用的是gradle 5.6.4 版本構(gòu)建項(xiàng)目的
image.png
然后再次重新構(gòu)建項(xiàng)目,也就是重新下載對(duì)應(yīng)Gradle的版本。
(當(dāng)然,也可以直接官網(wǎng)下載對(duì)應(yīng)版本copy到C:\Users\(用戶家目錄).gradle\wrapper\dists\)
出錯(cuò)原因分析
我這里出錯(cuò)大致因?yàn)橄螺dgradle時(shí),網(wǎng)絡(luò)出現(xiàn)錯(cuò)誤,導(dǎo)致文件下載錯(cuò)誤,接著導(dǎo)致as判斷出錯(cuò),無法自動(dòng)重新下載。因此,網(wǎng)絡(luò)好時(shí),重新下載就好了。
