Massimo Carli
01/23/2021, 4:31 PM@AssistedInject
class.
class CalculatorImpl @AssistedInject constructor(
private val logger: Logger,
@Assisted private val increment: Int
) : Calculator {
override fun addOne(a: Int) = a.inc().apply {
logger.log("New value is $this")
}
}
The @AssistedFactory
is the following
@AssistedFactory
interface CalculatorImplFactory {
fun create(
inc: Int
): CalculatorImpl
}
When I try to inject the CalculatorImplFactory
in an Activity like this
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
lateinit var calculatorFactory: CalculatorImplFactory
// ...
}
When I build I get a
CalculatorImplFactory cannot be provided without an @Provides-annotated method.
The documentations says that Dagger will create the implementation for the assisted factory and provide a binding for it.
but this doesn't seem to be true. What am I missing? ThanksMassimo Carli
01/23/2021, 4:36 PM2.28.3-alpha
for Hilt. With 2.31.2-alpha
everything is good 🙂