I'm stuck at this problem when I move from java to Kotlin. Dagger is not generating the DaggerComponent class. I've tried many ways to fix this. This is my Code :
app.gradle :
...
apply plugin: 'kotlin-kapt'
...
dependencies {
...
implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
provided 'javax.annotation:jsr250-api:1.0'
...
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
this is my project.gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.51'
ext.support_version = '27.1.1'
ext.glide_version = '4.7.1'
ext.glide_slider_version = '1.3.2'
ext.dagger_version = '2.17'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
...
And finally this is my component interface code :
@Component(modules = arrayOf(AppModule::class, DatabaseModule::class))
interface DIComponent {
fun inject(app:App)
}
I think that i did it correctly, I declare all the required code with the correct annotations. I've did clean and rebuild the project but it still doesn't work. i did the invalidate caches and restart etc. it's still doesn't work.
Did I make a mistake when declaring the component? Or is there something wrong with my Android Studio. I don't have any idea about this. It's really confusing me and made me stressful.
add @Singleton
@Singleton
@Component(modules = arrayOf(AppModule::class, DatabaseModule::class))
interface DIComponent {
fun inject(app:App)
}