Gradle Android Studio 中的错误:找不到“com.android.tools.build:gradle:7.1.1。”
Gradle error in Android Studio: Could not find “com.android.tools.build:gradle:7.1.1.”
我正在尝试将一个项目从 Eclipse 导入到 Android Studio。
在 Eclipse 中,我将其导出到 gradle,然后将其导入到 Android Studio。
注意:我是 gradle 的新手,对问题一无所知。
现在我得到这个错误:
> Configure project :
Running gradle version: 6.8
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'aBooks'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.1.1.
Searched in the following locations:
-
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.1/gradle-7.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
给出的 link 导致“找不到 404 页面”。
我系统上带有“gradle-7”的 gradle 文件是:
gradle 文件:
buildscript {
// added crl https://tomgregory.com/anatomy-of-a-gradle-build-script/
repositories {
mavenCentral()
}
println "Running gradle version: $gradle.gradleVersion"
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1' // **original error here**
// https://mvnrepository.com/artifact/com.android.tools.build/gradle
// implementation group: 'com.android.tools.build', name: 'gradle', version: '7.1.0-alpha01'
// https://mvnrepository.com/artifact/com.android.tools.build/gradle/7.1.0-alpha01
}
}
apply plugin: 'com.android.application' // 'android'
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation project(':CRLibs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
android {
compileSdk 26
buildToolsVersion "32.0.0"
buildFeatures {
prefab true
prefabPublishing true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml,
...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependenciesInfo {
includeInApk true
includeInBundle true
}
// no joy
plugins { // added crl https://developer.android.com/studio/releases/gradle-plugin#groovy
id 'com.android.application' version '7.0.0-alpha13' apply false
id 'com.android.library' version '7.0.0-alpha13' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
}
我尝试将“7.1.1”更改为“7.2”,但没有任何变化。我不知道如何解决这个问题。我搜索中给出的所有答案与此处的版本不匹配或没有帮助。
编辑1:
添加信息。当我转到文件->项目结构和项目时,我看到
请注意,Gradle 版本是空白的。如果我输入 6.8 或 7.1.1 并单击确定,我会得到相同的结果,然后如果我返回 Gradle 版本是空白的。
Gradle 当前版本识别出 6.8 版(请参阅错误消息的第 2 行。不知道这是否意味着什么。
这是我的 Gradel-6* 文件列表:
将 google()
添加到您的 repositories { }
区块。 Android Gradle 插件位于此处。
我正在尝试将一个项目从 Eclipse 导入到 Android Studio。 在 Eclipse 中,我将其导出到 gradle,然后将其导入到 Android Studio。 注意:我是 gradle 的新手,对问题一无所知。 现在我得到这个错误:
> Configure project :
Running gradle version: 6.8
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'aBooks'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.1.1.
Searched in the following locations:
-
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.1/gradle-7.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
给出的 link 导致“找不到 404 页面”。
我系统上带有“gradle-7”的 gradle 文件是:
gradle 文件:
buildscript {
// added crl https://tomgregory.com/anatomy-of-a-gradle-build-script/
repositories {
mavenCentral()
}
println "Running gradle version: $gradle.gradleVersion"
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1' // **original error here**
// https://mvnrepository.com/artifact/com.android.tools.build/gradle
// implementation group: 'com.android.tools.build', name: 'gradle', version: '7.1.0-alpha01'
// https://mvnrepository.com/artifact/com.android.tools.build/gradle/7.1.0-alpha01
}
}
apply plugin: 'com.android.application' // 'android'
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation project(':CRLibs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
android {
compileSdk 26
buildToolsVersion "32.0.0"
buildFeatures {
prefab true
prefabPublishing true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml,
...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependenciesInfo {
includeInApk true
includeInBundle true
}
// no joy
plugins { // added crl https://developer.android.com/studio/releases/gradle-plugin#groovy
id 'com.android.application' version '7.0.0-alpha13' apply false
id 'com.android.library' version '7.0.0-alpha13' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
}
我尝试将“7.1.1”更改为“7.2”,但没有任何变化。我不知道如何解决这个问题。我搜索中给出的所有答案与此处的版本不匹配或没有帮助。
编辑1: 添加信息。当我转到文件->项目结构和项目时,我看到
请注意,Gradle 版本是空白的。如果我输入 6.8 或 7.1.1 并单击确定,我会得到相同的结果,然后如果我返回 Gradle 版本是空白的。 Gradle 当前版本识别出 6.8 版(请参阅错误消息的第 2 行。不知道这是否意味着什么。 这是我的 Gradel-6* 文件列表:
将 google()
添加到您的 repositories { }
区块。 Android Gradle 插件位于此处。