Android Studio中的Gradle错误:无法找到“com.android.tools.build:升级版:7.1.1”,

js5cn81o  于 2023-03-03  发布在  Android
关注(0)|答案(2)|浏览(342)

我正在尝试将一个项目从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 :

所给链接指向一个“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 * 文件列表:

wwtsj6pe

wwtsj6pe1#

google()添加到您的repositories { }块。Android Gradle插件位于此处。

w6lpcovy

w6lpcovy2#

有同样的问题
这就是我的解决方案
类路径“com.android.tools.build:升级版本:7.2.0”

相关问题