无法找到 org.gradle.api.internal.artifacts.dependency.DefaultSelfResolvingDependency 类型的对象参数的方法 except()

Ely*_*lye 8 gradle android-gradle-plugin

我曾经有

implementation(group: "com.domain.package", name: "lib-name", version: "$ver") {
    exclude group: 'com.android.support'
    exclude group: 'com.squareup.okhttp3'
    exclude group: 'com.google.dagger'
}
Run Code Online (Sandbox Code Playgroud)

当我导入为 aar 时

implementation (files('libs/lib-name.aar')) {
    exclude group: 'com.android.support'
    exclude group: 'com.squareup.okhttp3'
    exclude group: 'com.google.dagger'
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误。

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method exclude() for arguments [{group=org.apache.commons}] on object of type 
org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency.
Run Code Online (Sandbox Code Playgroud)

想知道出了什么问题吗?

注意:我检查了Could not find method except() for argument [{module=support-v4}],这确保了额外的括号存在,我已经完成了。但这没有帮助。

小智 -2

问题可能是括号位置:

尝试:

implementation (files('libs/lib-name.aar'), {
    exclude group: 'com.android.support'
    exclude group: 'com.squareup.okhttp3'
    exclude group: 'com.google.dagger'
})
Run Code Online (Sandbox Code Playgroud)

步步为营

implementation (files('libs/lib-name.aar')) {
    exclude group: 'com.android.support'
    exclude group: 'com.squareup.okhttp3'
    exclude group: 'com.google.dagger'
}
Run Code Online (Sandbox Code Playgroud)