Reputation: 2994
I am trying to use Dagger 2 for dependency injection. Currently I am adding the depenecies like this.
In build.gradle
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
In app/build.gradle
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
testCompile 'junit:junit:
compile 'com.android.support:appcompat-v7:23.2.0'
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
}
The problem is, We are creating a SDK (module), which will be included by other apps so I don't want to include the dependency in build.gradle. Because of this, I will have to tell the other apps to include Dagger2
dependency in their main build.gradle file.
Also, let me know if there is any way to include dagger library using jar.
Thanks in advance :)
Upvotes: 3
Views: 1478
Reputation: 2743
Try this
add this to your build.gradle
dependencies {
// other classpath definitions here
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
Then in your app/build.gradle:
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
// apt command comes from the android-apt plugin
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
}
Note that the provided keyword refers to dependencies that are only needed at compilation.
Hope this helps
Upvotes: 2