当我使用 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
谁能帮忙,我将不胜感激,也将很高兴,谢谢...
添加中央 Maven 存储库
repositories {
mavenCentral()
}
可能的错误原因:
目前 android studio 似乎正在尝试从位置
org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10
下载库("https://dl.google.com/dl/android/maven2"
),但由于某种原因,它找不到 pom 文件,如错误中所述。在
google
文件中的 mavenCentral
中添加 repositories
和 build.gradle
.
.
.
repositories {
google()
mavenCentral()
}
.
.
.