Reputation: 17868
I have some libraries I use in mutliple projects. My code in the library is compatible with more versions of the library (older and newer ones). BUT there are changes in the library that are not compatible with all build versions.
I have an older project that I currently don't want to update to the newest build tools version so for this single project I would like to forcefully override a the dependency.
Normally I do exclude dependencies from libraries like following:
compile ("com.doomonafireball.betterpickers:library:1.6.0") {
exclude group: 'com.android.support', module: 'support-v4'
}
How can I exclude a dependency from local library project? I tried
compile project(':dialogs') {
exclude group: 'com.afollestad.material-dialogs'
}
But this does not compile...
EDIT
Here's my dialog library:
compile('com.afollestad.material-dialogs:core:0.8.4.2@aar') {
transitive = true;
}
compile('com.afollestad.material-dialogs:commons:0.8.4.2@aar') {
transitive = true;
}
And here's what I tried, but it does not work:
compile(project(':dialogs')) {
exclude group: 'com.afollestad.material-dialogs'
}
compile 'com.afollestad:material-dialogs:0.7.8.1'
Problem: it compiles and runs, but I get NoSuchMethod
exceptions. When I just comment out the 0.8.4.2 library lines and replace it with the 0.7.8.1 line (all in my library) everything works fine...
Upvotes: 2
Views: 5744
Reputation: 3739
Probably that should help: https://discuss.gradle.org/t/excluding-transitive-dependency-does-not-work-for-project-dependency/8719
This is a syntax issue. The closure in which you are calling exclude is being interpreted as an argument to the project() method, which is incorrect. Should look like so:
compile(project(':baseproject')) {
exclude group: 'com.miglayout'
}
See that compile wraps project with braces ()
Upvotes: 6