Can't cast 'application] as Application class to the ViewModelFactory
I'm trying to follow the android codelabs for room. I've faced some issue - I can't cast application while initializing ViewModel in Fragment, why is that? I've copy pasted this code to the MainActivity, and somehow the 'application' were casted (it wasn't red). I've added th Application class to the manifest.
Initializing variable in fragment
private val mViewModel: MyViewModel viewModels{
MyViewModelFactory((application as MyApplication).repository)
Application
class MyApplication:...