There's an object definition that contributes a binding:
@ContributesBinding(MyScope::class)
object Foo : Bar
// or
@ContributesMultibinding(MyScope::class)
object Foo : Bar
No method of factory generation (Anvil's generateDaggerFactories, Dagger with KAPT, or Dagger with KSP) has been enabled for that specific source set
Some other downstream Gradle module defines a component via @MergeComponent(...) that merges this binding.
Then
There will be an unresolved reference to a ***_Provide***Factory in the Dagger-generated component implementation (in a downstream Gradle module).
Fix
Simply enable factory generation via Anvil's generateDaggerFactories, or by using Dagger with KAPT or KSP.
Given a declaration like:
package bar
// imports
@ContributesBinding(Scope::class) // or @ContributesMultibinding
object FooImpl : Foo
Anvil will now generate this is in the same package:
package bar
// imports
@Module
@ContributesTo(scope = Scope::class)
@InternalBindingMarker(
originClass = Foo::class,
isMultibinding = false,
priority = "NORMAL",
)
public object FooImplAsBarFooToBarScopeBindingModule {
@Provides
public fun provideFoo(): Foo = FooImpl
}
That @Provides function must have a corresponding generated factory, or there will be an unresolved reference in the generated downstream component class.
package bar.app;
import bar.FooImplAsBarFooToBarScopeBindingModule_ProvideFooFactory; // this is unresolved
import bar.Foo;
import dagger.internal.DaggerGenerated;
import javax.annotation.processing.Generated;
@DaggerGenerated
@Generated(
value = "dagger.internal.codegen.ComponentProcessor",
comments = "https://dagger.dev"
)
public final class DaggerComponentInterface {
// ...
@Override
public Foo foo() {
// this is also unresolved
return FooImplAsBarFooToBarScopeBindingModule_ProvideFooFactory.provideFoo();
}
}
This is new as of 2.5.0-beta04.
When these are all true
There's an object definition that contributes a binding:
generateDaggerFactories
, Dagger with KAPT, or Dagger with KSP) has been enabled for that specific source set@MergeComponent(...)
that merges this binding.Then
There will be an unresolved reference to a
***_Provide***Factory
in the Dagger-generated component implementation (in a downstream Gradle module).Fix
Simply enable factory generation via Anvil's
generateDaggerFactories
, or by using Dagger with KAPT or KSP.Given a declaration like:
Anvil will now generate this is in the same package:
That
@Provides
function must have a corresponding generated factory, or there will be an unresolved reference in the generated downstream component class.