Thank you for your reply. I don't get this error in Java. Only in Kotlin. Could you please help?
t
tseisel
12/15/2019, 5:20 PM
I really recommend that you read the Android Architecture Guide : your code has some serious issues, be it in Java or Kotlin.
Android
ViewModel
should never keep a reference to a View, Fragment or Activity.
Your crash is due to the fact that
CardViewModel
has a constructor parameter, so the framework is unable to instantiate it (only no-args constructors are allowed, unless you specify a factory). Check your implementation of
ViewModelProvider.Factory
for
CardViewModel
.
👍 3
d
deactivateduser
12/16/2019, 9:18 AM
@tseisel Thank you so much. I really missed the first part of ViewModel. I have read about it. Now I understand how it's actually works. Thanks again. ✌🏼