android studio更新到3.2以后半沽,原先版本的gradle工具(2.1)已無法正常使用阀坏,更新后(4.6版本)厅克,問題解決。
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)
參考了幾篇網(wǎng)絡(luò)上的文章后瘾英,有了一些經(jīng)驗枣接,希望能幫到大家,
接下來以Failed to open zip file.這個錯誤為基礎(chǔ)缺谴,記錄解決過程:
1但惶、3.2版本以后的AS,默認(rèn)安裝的gradle插件是3.0.0+,其對應(yīng)的gradle版本是4.1+湿蛔。只有版本對應(yīng)上了膀曾,才能繼續(xù)往下走,否則第一個坑都跳不出去阳啥。具體更新方式請移步
2添谊、版本對應(yīng)后又會報以下異常,這是因為google苫纤,jcenter插件需要移步國內(nèi)鏡像才行
Could not find com.android.tools.build:gradle:3.2.0. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.0/gradle-3.2.0.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.0/gradle-3.2.0.jar Required by: project : Add Google Maven repository and sync project Open File Enable embedded Maven repository and sync project
具體修改分為兩步:
1、project下的build.gradle中,添加
allprojects {
repositories {
jcenter()
maven { url'https://maven.aliyun.com/repository/jcenter' }
}
}
2喊废、app下的build.gradle中,buildTypes目錄下添加
repositories {
maven {
url"http://maven.google.com"
? ? }
maven { url'https://maven.aliyun.com/repository/google' }
maven { url'https://maven.aliyun.com/repository/jcenter' }
maven { url'http://maven.aliyun.com/nexus/content/groups/public' }
}