实施项目在 gradle 中失败,并出现错误“由于接收器类型不匹配,以下候选者均不适用”

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

在我新创建的 Android 项目中创建新的应用程序模块(“design-kit”)后,我尝试通过将以下内容添加到依赖项来将我的应用程序链接到新模块

implementation project(":design-kit")

但是,该项目

implementation
不会出现错误,而另一个
implementation
的工作原理如下图所示(Android Studio 中显示红色)。

enter image description here

我尝试同步,但出现如下错误

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public val NamedDomainObjectContainer<Configuration>.implementation: NamedDomainObjectProvider<Configuration> defined in org.gradle.kotlin.dsl

我需要做什么才能使

implementation project
在我需要做的项目中有效?

我尝试询问 ChatGPT,但无济于事。

android gradle
1个回答
0
投票

事实证明,我使用的是 build.gradle.kts 文件而不是 build.gradle 文件。

语法应该是

    implementation(project(":design-kit"))
© www.soinside.com 2019 - 2024. All rights reserved.