Android導入包報錯問題Failed to complete Gradle Execution Cause: error in opening zip file.

這裏的話我參考了Stack overflow上的回答 先給出解釋 後面給出如何解決的辦法

An "error in opening zip file" tends to mean that a file that Gradle has downloaded has somehow become corrupted -- this might be the download of Gradle itself (which the wrapper does), or a dependency that Gradle has downloaded to run your build.

Gradle doesn't attempt to detect or resolve the problem, so you need to fix it manually. The solution is often to purge Gradle's download caches and let it get fresh copies of what it needs. To do that, delete the .gradle directories in both your home directory and in your project's root directory and try building again.

錯誤的打開zip ,往往意味着下載工具本身出錯。  好的 ,從這裏我分析出可能是gradle插件出了問題 ,但是又出於某種原因(如天朝牆的原因,很多開發者往往在導入github項目的時候,因爲要下載符合該項目配套的gradle插件是點了取消,但重新開啓時不能更新導致的) 好的,到這裏我猜測可能要手動的把gradle包給刪除。



好的,我隨便找了一個項目, ok 很明顯發現這個gradle插件版本號爲2.2.1  ,好了 那麼我們就去本地目錄裏刪除他 我們找到gradle-wrapper.properties這個文件


一般的話 ,目錄位置是在這 ,好的那麼我們進入2.2.1的目錄  記住是-all  不是-bin


一般正常的grdle是包含4項

大小在5MB左右 , 很好 ,那麼如果大小不正常的並且可能沒有4項的,那我們就刪除整個文件夾就ok了


到這裏,我們重新打開android studio ,我們又會進入 download gradle 的界面  !如果電腦上裝了360安全衛士的話,

我們可以比較下android studio 的下載速度 ,因爲被牆了 ,不可能太快你懂的。估算下100kb1s秒鐘,那麼我們大概下載完

一個gradle 插件要5分鐘左右!  好了請耐心等待吧 ,不要再亂點了!  

當然也可以下載離線的gradle包,不過比較麻煩 ,這裏就不做介紹啦。

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