输出程序时 Gradle 构建错误

问题描述 投票:0回答:2

当我使用 Gradle 在 Android Studio 中输出我的 Android 应用程序时,我遇到了一个问题,我收到这样的错误,错误出现在同步中,然后我尝试同步,AVD 正在工作,并且同步有效,但是现在,也许我在使用 Gradle 输出时遇到同样的问题,我认为这可能会有所帮助,我重置了我的笔记本电脑,所以所有内容都被删除,然后我重新安装了 Android Studio 和所有内容,这是我的第一个测试,并运行Gradle 也是如此。

这是我得到的build.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.10"
    repositories {
        google()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
        classpath "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10"
 
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        google()
    }
}
 
task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的错误

    Could not determine the dependencies of task ':app:kaptDebugKotlin'.

> Could not resolve all files for configuration ':app:kotlinKaptWorkerDependencies'.

> Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10.

Searched in the following locations:

- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-annotation-processing-gradle/1.5.10/kotlin-annotation-processing-gradle-1.5.10.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 :app



Possible solution:

- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

谁能帮忙,我将不胜感激,也将很高兴,谢谢...

android android-studio kotlin gradle
2个回答
18
投票

添加中央 Maven 存储库

repositories {
    mavenCentral()
}

可能的错误原因
目前 android studio 似乎正在尝试从位置

org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10
下载库(
"https://dl.google.com/dl/android/maven2"
),但由于某种原因,它找不到 pom 文件,如错误中所述。
如果您尝试检索的工件可以在存储库中找到,但没有“Maven POM”格式的元数据,则需要调整存储库声明的“metadataSources { ... }”。


0
投票

google
文件中的
mavenCentral
中添加
repositories
build.gradle

.
.
.
repositories {
  google()
  mavenCentral()
}
.
.
.
© www.soinside.com 2019 - 2024. All rights reserved.