Im using this kotlin Room project and trying to instantiate "viewModel" that needs a Dao parameter https://github.com/googlesamples/android-architecture-components/tree/master/BasicRxJavaSampleKotlin/app/src/main/java/com/example/android/observability
the project uses this line to to it:
private val viewModel: UserViewModel by viewModels()
but i cant get viewModels() to resolve. i noticed the project has this import
import androidx.activity.viewModels
but "activity" is red and not resolving.
i have another viewmodel B with no parameter that is instantiated by
val model = ViewModelProviders.of(this)[MyViewModel::class.java]
i am trying to figure out why the import is red for me
also is it possible to instantiate a viewmodel with parameters in the second way of instantiating?
please let me know if i need to include other files to determine.