Android Studio: Gradle Refresh Failed - Could not find com.android.tools.build:gradle:2.2.0-alpha6

前端 未结 7 1645
攒了一身酷
攒了一身酷 2020-12-24 01:46

I\'ve just pulled down an Android project from git, and Android Studio is giving me the following error whenever I attempt to open it;

Error:Could not find c         


        
7条回答
  •  情话喂你
    2020-12-24 02:25

    As gradle is updating the previous version will be replaced with new version so we have to change the gradle version in code as it would be referring to previous version and will show error like this

    Could not resolve all dependencies for configuration ':classpath'. Could not find com.android.tools.build:gradle:2.2.3. Searched in the following locations: file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar 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 https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar Required by: :: Open file

    The solution to this is that we add the repository in the build.gradle file like

    buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    

    OR

    GOTO the File Explorer and search

    C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle
    

    and see the Gradle name with latest version like

    Gradle 2.2.0
    Gradle 3.2.1
    Gradle 2.1.0
    

    and select the latest version like 3.2.1 and paste it in the build.gradle file in dependencies section like

    dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'}
    

提交回复
热议问题