Could not find method exclude() for arguments on object of type org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency

Viewed 3369

I used to have

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

When I import as aar

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

I got the following error.

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

Wonder what went wrong?

Note: I have check on Could not find method exclude() for arguments [{module=support-v4}], which ensure the extra parenthesis is there, that I have done. But it is not helping.

1 Answers

the problem might be the parenthesis location:

try:

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

in step of

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