본문 바로가기
오류노트

AndroidViewModel has no zero argument constructor

by 어컴띵 2021. 2. 9.

안드로이드 버젼 문제로 보임

 

AndroidViewModel has no zero argument constructor

stackoverflow.com/questions/61370134/androidviewmodel-has-no-zero-argument-constructor

 

AndroidViewModel has no zero argument constructor

I am trying to create an instance of my AndroidViewModel in MainActivity. When I do this I get the following error has no zero argument constructor Here is my RecipeViewModel package com.example.

stackoverflow.com

recipeViewModel = new ViewModelProvider(this).get(RecipeViewModel.class);

를 다음과 같이 수정함

recipeViewModel = new ViewModelProvider(this, ViewModelProvider.AndroidViewModelFactory.getInstance(this.getApplication())).get(RecipeViewModel.class);