Gradle下載
今天實驗的時候,突然發生了gradle下載失敗的問題,於是來調查下解決辦法。
錯誤信息:
Error:Unable to find method 'com.google.common.cache.CacheBuilder.build(Lcom/google/common/cache/CacheLoader;)Lcom/google/common/cache/LoadingCache;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
解決辦法一
刪除下面的文件夾:自己目錄和項目目錄
解決辦法二
下載gradl
使用迅雷等下載gradle版本後,解壓到指定目錄下。
下載版本查看:
直接複製上圖的連接,到迅雷中打開網頁,就會自動下載。
安裝
打開Android Studio自動生成文件夾/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv
當Android Studio下載過gradle-2.14.1-all之後(不管成功失敗),就會在C:/Users/用戶名/.gradle/wrapper/dists(或自己修改的.gradle緩存目錄/wrapper/dists)
中出現gradle-2.14.1-all文件夾.
打開之後是一串以無規律字符命名的文件夾,我的是8bnwg5hd3w55iofp58khbp6yv,這個可能因人而異。
接下來開始操作:
- 將下載好的壓縮包和解壓後的文件夾複製到上述文件夾下:
- 刪除gradle-2.14.1-all.zip.part
- 複製一份gradle-2.14.1-all.zip.lck文件,重命名爲gradle-2.14.1-all.zip.ok;
- 重啓as。