I have updated today my build.gradle file to the latest version
classpath 'com.android.tools.build:gradle:3.6.3' and the latest ext.kotlin_version = '1.3.72'
and I get the following error that is in the title at: instance().
private val viewModelFactory: ListViewModelFactory by instance()
This is my Factory class:
class ListViewModelFactory(
private val listRepository: ListRepository
) : ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return ListViewModel(listRepository) as T
}
}
Can someone explain why this occurred and how can I get rid of the error. Thank you in advance!
P.S. if it is of any help I use kodein and here is my bind
bind() from provider { ListViewModelFactory(instance()) }
can you try private val viewModelFactory by instance<ListViewModelFactory>()
Try this : Replace
private val factory : AuthViewModelFactory by instance()
to
private val factory by instance<AuthViewModelFactory>()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With