2017-07-17 109 views
1

當我嘗試構建我的android項目時,它顯示一些gradle錯誤。錯誤如下,構建Android項目時出錯

Error:Could not find com.android.tools.build:gradle:2.2.3. 
Searched in the following locations: 
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom 
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar 
Required by: 
    D4D.libs:ViewPagerIndicator-Library:unspecified 

如果有人知道如何解決這個錯誤,請幫助我。

的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 

    dependencies { 

     classpath 'com.android.tools.build:gradle:2.2.3' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 
+0

[搖籃錯誤的可能重複:找不到com.android.tools.build:gradle:2.2.3](https://stackoverflow.com/questions/41570435/gradle -error-could-not-find-com-android-tools-buildgradle2-2-3) – Sree

回答

0

這是因爲構建過程是無法找到Maven倉庫的依賴。添加jcenter()以及mavenCentral()在您的項目級別build.gradle文件。

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.0' 
    } 
} 

see this

+0

沒有。錯誤仍然發生。 – Astro

0

根據這個答案https://stackoverflow.com/a/39654136/8284461,也許你需要在你的倉庫中添加mavenCentral()。在gradle這個會是這樣

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 
    } 

    dependencies { 

     classpath 'com.android.tools.build:gradle:2.2.3' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
}