google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.45k stars 2.02k forks source link

[KSP2] dagger-android `@ContributesAndroidInjector` results in `PROCESSING_ERROR` due to `error.NonExistentClass` #4494

Closed mcumings closed 2 weeks ago

mcumings commented 2 weeks ago

When using:

Given an injectable class:

class Foo @Inject constructor()

and a Dagger module for that class:

@Module
interface FooModule {
    @ContributesAndroidInjector
    fun contributeFoo(): Foo
}

and a module which includes that module:

@Module(includes = [ FooModule::class ])
interface Module

Results in the following processing error:

e: [ksp] BindingMethodProcessingStep was unable to process 'bindAndroidInjectorFactory(repro.ksp.issue3.FooModule_ContributeFoo.FooSubcomponent.Factory)' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): repro.ksp.issue3.FooModule_ContributeFoo
    => element (INTERFACE): repro.ksp.issue3.FooModule_ContributeFoo.FooSubcomponent
    => element (INTERFACE): repro.ksp.issue3.FooModule_ContributeFoo.FooSubcomponent.Factory
    => annotation type: Factory
    => type (ERROR annotation type): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
mcumings commented 2 weeks ago

Appears to be fixed in/via KSP 2.0.21-1.0.26