I am trying to write a sample app using Android architecture components and but even after trying for days I could not get it to work. It gives me the above exception.
Extend AndroidViewModel from your ViewModel class.
public class YourViewModel extends AndroidViewModel { public YourViewModel(Application application) { super(application); //Todo: ... } }