Android Studio 中的 Gradle 错误:找不到“com.android.tools.build:gradle:7.1.1”。

cli*_*310 3 android gradle android-studio

我正在尝试将项目从 Eclipse 导入到 Android Studio 中。\n在 Eclipse 中,我将其导出到 gradle,然后将其导入到 Android Studio 中。\n注意:我是 gradle 新手,对问题没有洞察力。\n现在我收到此错误:

\n
> Configure project :\n    Running gradle version: 6.8\n\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nA problem occurred configuring root project \'aBooks\'.\n > Could not resolve all artifacts for configuration \':classpath\'.\n > Could not find com.android.tools.build:gradle:7.1.1.\n Searched in the following locations:\n   - \nhttps://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.1/gradle-7.1.1.pom\n 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.\n Required by:\n     project : \n
Run Code Online (Sandbox Code Playgroud)\n

给定的链接指向 \xe2\x80\x9c404 页面未找到\xe2\x80\x9d。

\n

我的系统上带有 \xe2\x80\x9cgradle-7\xe2\x80\x9d 的 gradle 文件是:

\n

我的 Gradle 文件 gradle-7*

\n

渐变文件:

\n
buildscript {\n// added crl  https://tomgregory.com/anatomy-of-a-gradle-build-script/\nrepositories {\n    mavenCentral()\n}\nprintln "Running gradle version: $gradle.gradleVersion"\ndependencies {\n    classpath \'com.android.tools.build:gradle:7.1.1\'  // **original error here**\n    // https://mvnrepository.com/artifact/com.android.tools.build/gradle\n   // implementation group: \'com.android.tools.build\', name: \'gradle\', version: \'7.1.0-alpha01\'\n    //  https://mvnrepository.com/artifact/com.android.tools.build/gradle/7.1.0-alpha01\n}\n}\n\napply plugin: \'com.android.application\'   // \'android\'\n\n\ndependencies {\nimplementation fileTree(dir: \'libs\', include: \'*.jar\')\nimplementation project(\':CRLibs\')\nimplementation \'com.android.support:support-annotations:28.0.0\'\nimplementation \'androidx.legacy:legacy-support-v4:1.0.0\'\n\n}\n\nandroid {\ncompileSdk 26\nbuildToolsVersion "32.0.0"\n\nbuildFeatures {\n    prefab true\n    prefabPublishing true\n}\n\n\nsourceSets {\n    main {\n        manifest.srcFile \'AndroidManifest.xml\'\n        java.srcDirs = [\'src\']\n        resources.srcDirs = [\'src\']\n        aidl.srcDirs = [\'src\']\n        renderscript.srcDirs = [\'src\']\n        res.srcDirs = [\'res\']\n        assets.srcDirs = [\'assets\']\n    }\n\n    // Move the tests to tests/java, tests/res, etc...\n    instrumentTest.setRoot(\'tests\')\n\n    // Move the build types to build-types/<type>\n    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, \n...\n    // This moves them out of them default location under src/<type>/... which would\n    // conflict with src/ being used by the main source set.\n    // Adding new build types or product flavors should be accompanied\n    // by a similar customization.\n    debug.setRoot(\'build-types/debug\')\n    release.setRoot(\'build-types/release\')\n}\ncompileOptions {\n    sourceCompatibility JavaVersion.VERSION_1_8\n    targetCompatibility JavaVersion.VERSION_1_8\n}\ndependenciesInfo {\n    includeInApk true\n    includeInBundle true\n}\n\n// no joy\nplugins { // added crl https://developer.android.com/studio/releases/gradle-plugin#groovy\n    id \'com.android.application\' version \'7.0.0-alpha13\' apply false\n    id \'com.android.library\' version \'7.0.0-alpha13\' apply false\n    id \'org.jetbrains.kotlin.android\' version \'1.5.31\' apply false\n}\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试将 \xe2\x80\x987.1.1\xe2\x80\x99 更改为 \xe2\x80\x987.2\xe2\x80\x99 没有变化。我不知道如何解决这个问题。我搜索中给出的所有答案与此处的版本不匹配或者没有帮助。

\n

编辑1:\n添加信息。当我转到文件->项目结构和项目时,我看到

\n

文件->项目结构和项目

\n

请注意,Gradle 版本是空白的。如果我输入 6.8 或 7.1.1 并单击“确定”,我会得到相同的结果,然后如果我返回,Gradle 版本为空。\nGradle 版本 6.8 在当前版本中被识别(请参阅错误消息的第 2 行。Don\不知道这是否意味着什么。\n这是我的 Gradel-6* 文件的列表:

\n

格兰德尔6.8文件

\n

laa*_*lto 7

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