Hi all, Is there a way how I can replace dependenc...
# squarelibraries
m
Hi all, Is there a way how I can replace dependencies with Anvil using
replaces
in a separate android test module (apply com.android.test) ?
Copy code
@Module
@ContributesTo(
    scope = AppScope::class,
    replaces = [ActualModule::class],
)
object TestActualModule {

    @Provides
    @SingleIn(AppScope::class)
    fun providesTestImpl(): TestImpl = TestImpl()
}
Anvil correctly generates Factory class for this, but it's not contributed in the
DaggerAppComponent
j
Are you able to share a branch that reproduces the issue? Hard to advise based on just this snippet -- what you're trying to do should be possible but it sounds like some element of the surrounding setup is resulting in
TestActualModule
not being picked up before the graph is merged
m
@Joel Wilcox I managed to find the issue in my setup. I was not applying
kapt(dagger)
in the test module, which means
TestComponent
was not generated. It was working within app/androidTest, but for other modules I use anvil compiler, so I was blindly copying w/o thinking.
anvil { generateDaggerFactories = true }
I appreciate you getting back to me though!
👍 1