Here is the solution to solve Viewmodelproviders error
//Creating a ViewModel instance
//MyViewModel model = ViewModelProviders.of(this).get(MyViewModel.class); //This method is deprecated
MyViewModel model = new ViewModelProvider(this).get(MyViewModel .class);