Configuration in Gradle file and Useful Resource for Dagger - SatanPandeya/Dagger-2.0-Demo GitHub Wiki
Welcome to the Dagger-2.0-Demo wiki !!!
Configration in gradle file !!!
-> We need to modify the project's build.gradle by using :
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
-> We need to modify the build.gradle in your project's app folder and modify it as shown below :
i) Use
apply plugin: 'com.neenbedankt.android-apt'
and
ii) Use
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0' // Dagger 2 and Compiler
compile 'com.google.dagger:dagger:2.2'
apt "com.google.dagger:dagger-compiler:2.2"
// Needed for @Generated annotation (missing in Android API jar)
// No longer needed in dagger >= 2.1-SNAPSHOT (github.com/google/dagger/issues/95)
compile 'javax.annotation:jsr250-api:1.0'
}
Resources for learning Dagger
i) http://code.tutsplus.com/tutorials/dependency-injection-with-dagger-2-on-android--cms-23345
ii) http://vogella.com/tutorials/Dagger/article.html#create-example-project-for-the-usage-of-dagger-2