找不到类型为org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency的对象上的参数的方法exclude()

时间:2018-11-05 06:04:38

标签: gradle android-gradle

我曾经拥有

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'
}

当我作为aar导入

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

我遇到以下错误。

* 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.

想知道出什么问题了吗?

注意:我已检查Could not find method exclude() for arguments [{module=support-v4}],以确保已经完成了多余的括号。但这没有帮助。

1 个答案:

答案 0 :(得分:0)

问题可能出在括号位置:

尝试:

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

步骤

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