Miguel12/22/2021, 10:10 AM
In my dagger class I have:
data class Example @Inject constructor( val x: X, val string: String? = x.method() )
but whenever I want to instantiate an
@Provides @Singleton fun x() = X()
object. it asks me for
dependency which should always be injected. Is there any approach of how I can deal with this?
Daniel Perez12/22/2021, 2:54 PM
variable, try adding @JvmOverloads to the constructor right after @Inject so Dagger can see both constructors. If that doesn’t work, I would move your
variable as a member variable instead of a constructor parameter.