'Could not find com.android.tools.build: gradle : 4.2.2.'



我正在使用react native制作android应用程序,我得到的错误是无法找到构建gradle

这里是android studio中build gradle的内容。发行版的url是gradle 6.9。

ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")

}
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

maven { url 'https://www.jitpack.io' }
}
}```
have being trying to solve this for hours with no avail. please do help out

将其放在build.gradle中以取代jcenter中的所有依赖项

allprojects {
repositories {
def REPOSITORY_URL = "https://repo1.maven.org/maven2"
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Local Maven repo containing AARs with JSC library built for Android
url "$rootDir/../node_modules/jsc-android/dist"
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}