I am using Dagger2 for DI in my Android app, and using this code for injecting classes into my Activity is fine:
@field:[Inject ApplicationContext]
lateinit var context: Context
but, lateinit
modifier is not allowed on primitive type properties in Kotlin (for instance Boolean
), how can I do something like this?
@field:[Inject Named("isDemo")]
lateinit var isDemo: Boolean
when I remove lateinit
from this code I get this error Dagger does not support injection into private fields
@JvmField @field:[Inject Named("isDemo")] var isDemo: Boolean = false
– Paresis