android studio更新到3.2以后,原先版本的gradle工具(2.1)已無(wú)法正常使用,更新后(4.6版本),問(wèn)題解決。
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)驗(yàn),希望能幫到大家,
接下來(lái)以Failed to open zip file.這個(gè)錯(cuò)誤為基礎(chǔ),記錄解決過(guò)程:
1、3.2版本以后的AS,默認(rèn)安裝的gradle插件是3.0.0+,其對(duì)應(yīng)的gradle版本是4.1+。只有版本對(duì)應(yīng)上了,才能繼續(xù)往下走,否則第一個(gè)坑都跳不出去。具體更新方式請(qǐng)移步
2、版本對(duì)應(yīng)后又會(huì)報(bào)以下異常,這是因?yàn)間oogle,jcenter插件需要移步國(guó)內(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' }
}
