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

Viewed 6338

I'm totally new to android studio and came up to this error that says it can not download gradle-3.5.1.pom and gradle-3.5.1.jar from google or jcenter repositories. But when I tried downloading them manually it was easy and straight forward though.

Here is the error text :

ERROR: Could not find com.android.tools.build:gradle:3.5.1.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
  - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.pom
  - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.1/gradle-3.5.1.jar
Required by:
    project :
Open File

I know that this is going to make me crazy because these gradle stuff always been a problem to all.

2 Answers

Make sure you have google() repo in your project's level build.gradle file. Here's an example:

build.gradle

buildscript {
    repositories {
        google() // check if you have this
        jcenter()

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

allprojects {
    repositories {
        google() // and this
        jcenter()

    }
}

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

Disable Offline Work in Android studio if you have enabled the checkbox and sync project. Once the project is synced, you can enable the checkbox and run the app as long as you do not add another dependency manually. It will automatically download the required dependencies. File>Settings>Build>Gradle

Related