Make sure your view Model class is public
Make sure your view model class constructor is public
Make sure you have added the dependency in your gridle file for lifecycle also if you use room and other libries you have added …
if you create object any other dependent class in your view model class constructor . Other class can throw error to create the instance of viewModel
annotationProcessor deps.lifecycle.compiler
kapt deps.lifecycle.compiler
annotationProcessor deps.room.compiler
kapt deps.room.compiler
使用kotlin的时候必须要用kapt引用