【发布时间】:2021-11-09 17:54:20
【问题描述】:
所以我在 Gradle 文件中实现了一些依赖项,当我尝试同步它时,我得到了
Build file '/home/qwirrr/AndroidStudioProjects/ClockIn/build.gradle' line: 9
A problem occurred evaluating root project 'ClockIn'.
> Could not find method implementation() for arguments [androidx.fragment:fragment:1.3.6] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Gradle 文件如下所示:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'com.google.android.material:material:1.0.0'
classpath "com.android.tools.build:gradle:7.0.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我尝试将implementation 更改为compile,甚至更改类路径行中的Gradle 版本,但没有成功。
我该如何解决这个问题?
注意:我使用的是 Pop_OS! 20.04 LTS 如果重要的话
【问题讨论】:
-
您正在将依赖项添加到根构建 gradle,将它们添加到您应用的 build.gradle
-
implementation配置为added by the Java plugin。所以你应该将plugins { id 'java' }添加到你的build.gradle 的顶部。在buildscript块中,您只能使用classpath。