Im trying to use Dagger 2 on android. I previously had it working and i had an appModule injecting dependencies into specific classes in the app. My Issue is that iam getting th
Setting up a stand-alone project in Android Studio 2.3, I updated the default gradle files as follows to get the generated Component file. Added lines have comment // dagger2 addition
PROJECT build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// dagger2 addition
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
// dagger2 addition
mavenCentral()
maven{
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
APP MODULE build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt' // dagger2 addition
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.demo.dagger2demo"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
// dagger2 addition
compile 'com.google.dagger:dagger:2.+'
apt "com.google.dagger:dagger-compiler:2.+"
}