Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find com.android.tools.build:gradle:5.1.1

I have tried all solution i can find online, like adding mavenCentrals and all that. I can find 5.1.1 under .gradle, but it's complaining it does not find any version after 2.3 in the repo.

Could not find com.android.tools.build:gradle:5.1.1. Searched in the following locations: - file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/5.1.1/gradle-5.1.1.pom - file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/5.1.1/gradle-5.1.1.jar - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/5.1.1/gradle-5.1.1.pom - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/5.1.1/gradle-5.1.1.jar - https://jcenter.bintray.com/com/android/tools/build/gradle/5.1.1/gradle-5.1.1.pom - https://jcenter.bintray.com/com/android/tools/build/gradle/5.1.1/gradle-5.1.1.jar Required by: project : Open File

here's my build.gradle file

buildscript {
    ext.kotlin_version = '1.3.0'
    repositories {
        google()
        jcenter()


    }

    dependencies {
        classpath 'com.android.tools.build:gradle:5.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:3.4.0'
    }
}

allprojects {
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.google.firebase') {
                details.useVersion "15.+"
            }
            
        }
    }
    repositories {
        google()
        jcenter()

    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

And I have distributionUrl = https://services.gradle.org/distributions/gradle-5.1.1-all.zip in gradle-wrapper.properties

like image 391
Zhang Bruce Avatar asked May 07 '19 05:05

Zhang Bruce


1 Answers

When you update Android Studio, you may receive a prompt to automatically update the Android Gradle plugin to the latest available version. You can choose to accept the update or manually specify a version based on your project's build requirements.

You should set PROPER classpath version.

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

Set the Gradle version to 6.1.1 in the gradle-wrapper.properties file.

distributionUrl = https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Read Android Gradle plugin.

 Plugin version ----> Required Gradle version

 3.1.0+ ----> 4.4+
 3.2.0  ----> 3.2.1 4.6+
 3.3.0  ----> 3.3.2 4.10.1+
 3.4.0+ ----> 5.1.1+
 4.0.1  ----> 6.1.1
like image 75
IntelliJ Amiya Avatar answered Oct 23 '22 00:10

IntelliJ Amiya