DaggerAppComponent not created
In Kotlin, we have to add kapt compiler plugin to use Dagger 2.
In your app gradle, add this plugin
apply plugin: 'kotlin-kapt'
And add dependencies as below
dependencies
{
implementation "com.google.dagger:dagger:$latest_version"
kapt "com.google.dagger:dagger-compiler:$latest_version"
implementation "com.google.dagger:dagger-android:$latest_version"
kapt "com.google.dagger:dagger-android-processor:$latest_version"
implementation "com.google.dagger:dagger-android-support:$latest_version"
kapt "com.google.dagger:dagger-android-support:2.12"
}
See Kotlin Documentation
With the dependencies listed below everything works:
If you are using Kotlin
apply plugin: 'kotlin-kapt'
dependencies {
def daggerVer = 2.27 // or latest version
implementation "com.google.dagger:dagger:$daggerVer"
implementation "com.google.dagger:dagger-android-support:$daggerVer"
kapt "com.google.dagger:dagger-android-processor:$daggerVer"
kapt "com.google.dagger:dagger-compiler:$daggerVer"
}
If you are using Java:
dependencies {
def daggerVer = 2.27 // or latest version
implementation "com.google.dagger:dagger:$daggerVer"
implementation "com.google.dagger:dagger-android-support:$daggerVer"
annotationProcessor "com.google.dagger:dagger-android-processor:$daggerVer"
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVer"
}
See google tutorial
You can find the latest release number here.
in my case (currently using kotlin)
i use this build gradle
implementation 'com.google.dagger:dagger:2.24'
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'
implementation 'com.google.dagger:dagger-android-support:2.24'
after sync gradle,
I quit Android studio (Command + Q).
Delete folder "build" inside 'app' folder
reopen Android Studio
DaggerAppComponent created.