6

I have project A, which used to have module A1, that used dagger v. 1.2.2. Now I'd like to add to project A, module A2, that has dependency on dagger v. 2.0. But I can't because these two dagger libs are in conflict. Can I approach somehow multiple versions of library in different android modules?

Fishman
  • 1,737
  • 1
  • 25
  • 42

3 Answers3

2

You can't have both.

You need to exclude the conflicting libraries from dependencies:

configurations {
    all*.exclude group: 'com.google.android', module: 'support-v4'
}

dependencies {
    compile 'com.android.support:support-v4:13.0.0'
}

From: https://github.com/stephanenicolas/robospice/issues/161

OR

dependencies {
    compile("org.gradle.test.excludes:api:1.0") {
        exclude module: 'shared'
    }
}

From: https://docs.gradle.org/current/userguide/dependency_management.html #52.4.7

shkschneider
  • 17,833
  • 13
  • 59
  • 112
0

You need to exclude the dagger v. 1.2.2 library and let the dagger v. 2.0. The latter normally will be back compatible. Look at the gradle doc about how to exclude specific dependency. https://docs.gradle.org/current/userguide/dependency_management.html

fab
  • 790
  • 6
  • 10
0

Why do you wan to t keep both of them? I don't think if it is possible, you should go for one library only. And here you should use the latest one, as I think if the latest one is added the older one doesn't matter. Check out these links if they help you with dagger...

Dagger dependencies when overriding graph with mock module causes NoClassDefFoundError

How to use dagger in a android library project

Dagger dependencies when overriding graph with mock module causes NoClassDefFoundError

Community
  • 1
  • 1
Rohit Jagtap
  • 1,660
  • 1
  • 14
  • 12
  • Because I have working project that uses 1.2.2. I want only to write new, independent library, that this project will use. Can I configure this independent library not to conflict with my existing project? – Fishman Sep 04 '15 at 10:15
  • not sure about that, when you use both of them does it give error while building or while running the app? – Rohit Jagtap Sep 04 '15 at 10:23
  • While building. I don't want to use 1.2.2 in module A2. I'd like module A1 to use 1.2.2, module A2 to use 2.0. – Fishman Sep 04 '15 at 10:27
  • Sorry bro, am not sure if I can answer, checkout the links in the edited answer though... – Rohit Jagtap Sep 04 '15 at 10:42