Miguel
12/22/2021, 10:10 AMdata class Example @Inject constructor(
val x: X,
val string: String? = x.method()
)
In my dagger class I have:
@Provides
@Singleton
fun x() = X()
but whenever I want to instantiate an Example
object. it asks me for x
dependency which should always be injected. Is there any approach of how I can deal with this?Daniel Perez
12/22/2021, 2:54 PMstring
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 string
variable as a member variable instead of a constructor parameter.