Looking at the Google docs for ViewModel, they show the below sample code on how to get a ViewModel:
val model = ViewModelProviders
I'm using android X and also had this issue.
First of all, you should add these dependencies to your Gradle:
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
In my case, the $lifecycle_version was 2.2.0-rc02
Second:
The import for the ViewModelProvider should be:
import androidx.lifecycle.ViewModelProvider
Than you can initial your vIewModel like the examples below:
val viewModel = ViewModelProvider(this, YourFactoryInstace).get(MainViewModel::class.java)
val viewModel = ViewModelProvider(this).get(MainViewModel::class.java)