I am using dagger2 in my android application. It is not generating dagger component classes even though there is no errors.
I have enabled the annotation processors in the setttings and restart my android studio but that didn't work for me. I read this thread too Dagger2 not generating Daggercomponent classes and read on one thread that apt
is deprecated so I am using annotationProcessor
Base Module build.gradle
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
baseFeature true
defaultConfig {
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
application project(':app')
feature project(":main")
feature project(":tv")
api 'com.android.support:appcompat-v7:26.0.2'
api 'com.android.support.constraint:constraint-layout:1.0.2'
api 'com.android.support:design:26.0.2'
api "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
api "org.jetbrains.anko:anko-commons:$anko_version"
api "android.arch.lifecycle:runtime:1.0.0-alpha9"
api "android.arch.lifecycle:extensions:1.0.0-alpha9"
kapt "android.arch.lifecycle:compiler:1.0.0-alpha9"
api 'com.squareup.retrofit2:retrofit:2.3.0'
api "com.squareup.retrofit2:converter-moshi:2.0.0"
api 'com.google.dagger:dagger:2.11'
kapt 'com.google.dagger:dagger-compiler:2.11'
api 'com.github.bumptech.glide:glide:4.0.0'
kapt 'com.github.bumptech.glide:compiler:4.0.0'
// new version 1.5.2 has some multi dex issue
debugApi 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseApi 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
}
repositories {
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
tv feature build.gradle
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation project(':base')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
ext.anko_version = '0.10.1'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
NetComponent.kt
@Component(modules = arrayOf(AppModule::class, NetModule::class))
interface NetComponent {
fun inject(activity: MainActivity)
}
apt
generates dagger classes inside apt directory but there is no such dagger generated classes now even though I searched in entire project directory.
I see that its not generating DaggerNetComponent
class, as there is no errors too on compilation. Does anyone know what could be the issue ?