Failed to open zip file.

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

jcenter插件需要移步國(guó)內(nèi)鏡像

具體修改分為兩步:

1、project下的build.gradle中,添加

allprojects {

repositories {

jcenter()

maven { url'https://maven.aliyun.com/repository/jcenter' }

}

}

project下的build.gradle中,添加

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' }

}

app下的build.gradle中,buildTypes目錄下添加
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容