Mikołaj Karwowski
10/25/2021, 9:59 AM[kapt] di.HeaterModule: Can't reference type 'Heater' from default package in Java stub.
as a warning and the error is:
error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this interface because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public abstract interface HeaterModule {
To be clear, this is my module:
@Module
interface HeaterModule {
//Tried both
// @Binds
// fun bindHeater(heater: SmallHeater): Heater
@Provides
fun provideHeater(): Heater {
return SmallHeater()
}
}
The component that doesn't even do anything:
@Component(modules = [HeaterModule::class])
interface TeaComponent{
// fun teaMaker(): TeaMaker
}
And the cherry on the top where I suspect the errors to be, but can't find them i.e. build.gradle.kts
file:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("kapt") version "1.5.31"
kotlin("jvm") version "1.5.10"
application
}
group = "me.mkarwowski"
version = "1.0-SNAPSHOT"
kapt {
generateStubs = true
keepJavacAnnotationProcessors = true
}
repositories {
mavenCentral()
}
dependencies {
implementation( "com.google.dagger:dagger:2.39.1")
annotationProcessor( "com.google.dagger:dagger-compiler:2.39.1")
kapt( "com.google.dagger:dagger-compiler:2.39.1")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnit()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClass.set("MainKt")
}
Am I doing anything obviously wrong here?
I'll upload it to github in a second so You can reproduce itwasyl
10/25/2021, 10:04 AMkapt
and annotationProcessor
configurations, Dagger works just as well when running just in kapt
wasyl
10/25/2021, 10:05 AMgenerateStubs = true
is still needed. Plus, you’re using different Kotlin and Kapt versions, which seems offMikołaj Karwowski
10/25/2021, 10:12 AMMikołaj Karwowski
10/25/2021, 10:16 AMCarl Benson
10/27/2021, 7:50 AM