Android Studio報錯:ERROR: Failed to resolve: com.android.support:appcompat-v7:28.0.+

小山研磨程式碼發表於2019-08-18

Android Studio報錯:ERROR: Failed to resolve: com.android.support:appcompat-v7:28.0.+


今天新匯入一個Project專案,上來就報錯找不到類庫,Google狠起來自己的兒子都編譯不過了麼?吐血,如下:

ERROR: Failed to resolve: com.android.support:appcompat-v7:28.0.+
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:recyclerview-v7:28.0.0
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app

嘗試各種Clear、Rebuild無果後放棄了,還得去StackOverflow尋找良方,果然不負眾望,找到了答案:
Failed to resolve: com.android.support:appcompat-v7:28.0
專案級Gradle中repositories的jcenter()下一行新增如下maven程式碼即可:

allprojects {
    repositories {
        jcenter()
        maven {// here we go!!
            url 'https://maven.google.com'
        }
    }
}

再編譯,完美執行。

原來 Android Support Library dependencies 都是從 Android SDK Manager 裡面下載的,現在新版本必須從 Google 的 Maven 倉庫裡面去下載。

相關文章