google/dagger

error when ksp.useKSP2=true

ber4444 opened this issue · 2 comments

Using KSP 2 (kotlin 2.0.0-RC2, ksp 2.0.0-RC2-1.0.20), the build fails with:

e: [ksp] ModuleProcessingStep was unable to process 'com.xxx.common.di.CommonModule' because '<error>' could not be resolved.

Dependency trace:
    => element (INTERFACE): com.xxx.common.di.CommonModule
    => annotation type: dagger.Module
    => annotation: @dagger.Module(includes={com.xxx.common.remoteconfig.di.ConfigurationModule}, subcomponents={<error>})
    => annotation value (TYPE_ARRAY): subcomponents={<error>}
    => annotation value (TYPE): subcomponents=<error>

If type '<error>' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type '<error>' is on your classpath.
e: [ksp] ModuleProcessingStep was unable to process 'com.xxx.common.remoteconfig.di.ConfigurationModule' because '<error>' could not be resolved.

My code looks pretty simple:

@Module
interface ConfigurationModule {
    @Binds
    @Singleton
    fun configurationUseCase(impl: ConfigurationUseCaseImpl): ConfigurationUseCase
}
...
@Module(includes = [ConfigurationModule::class])
interface CommonModule

Going back to ksp 1 is the only workaround?

Hi, @ber4444 , thanks for the report. Unfortunately Dagger doesn't work with KSP 2 yet as it contains some breaking changes and we're still migrating a library Dagger uses underneath(https://issuetracker.google.com/issues/314151707). I'm afraid you'll have to use KSP 1 for now.

Closing to consolidate with a single KSP2 issue: #4303