Error:Failed to open zip file. Gradle's dependency cache may be corrupt

在使用AndroidStudio直接導入GitHub中的源碼過程中,AS出現了某個過程感覺十幾分鍾了,其實代碼已經從GitHub中拉下來了,應該是AS執行項目配置時出了問題,遂直接結束了AS的進程;
從新打開AS時,Sync Gradle報錯:

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)

仔細研究錯誤應該是GradleWrapper出了問題,此Github項目使用的是gradle-3.4.1,本地沒有這個版本的緩存,於是AS自動從網絡下載,之前導入時AS有個過程執行慢,是因爲其在下載慢。(其實手動下載會快點兒)

查看目錄
~/.gradle/wrapper/dists/gradle-3.4.1-all/
目錄下的zip文件大小纔不到十兆,肯定沒有下載完,所以才報無法open zip file;

刪除gradle-3.4.1-all目錄,從新打開AS就不會報錯了,但是會從新自動下載。。開始慢的話只能手動下載了。

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