Home > Back-end >  Could not find com.android.tools.build:gradle:7.3.1
Could not find com.android.tools.build:gradle:7.3.1

Time:12-13

I installed Android Studio for the first time (2021.3.1.17) and proceeded to import an Eclipse/ADT project of mine.

The import of the project itself seems to have gone well, but I received the following error:

Could not find com.android.tools.build:gradle:7.3.1.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/7.3.1/gradle-7.3.1.pom

I added to the project's build.gradle the following:

    maven {
        url "https://maven.google.com"
    }

so that it now has:

// 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:7.3.1'
    }
}

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
}

But I am still getting this error.

What am I missing? How can I fix this?

CodePudding user response:

Problem solved by moving maven clause from allprojects to buildscript such that the entire build.gradle is now:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Also note that the compile configuration has been deprecated since Gradle 4.10 (Aug 27, 2018), and was finally removed in Gradle 7.0 (Apr 9, 2021), replaced by implementation.

  • Related