안드로이드 개발 팁 블로그

[Hilt,Dagger]cannot access DefaultActivityViewModelFactory 본문

카테고리 없음

[Hilt,Dagger]cannot access DefaultActivityViewModelFactory

tiii 2021. 4. 16. 23:44
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

dagger 2.28에서 2.34 마이그레이션을 진행하던 중 아래와 같은 이슈가 발생하였다.

> Task :app:kaptDebugKotlin
error: cannot access DefaultActivityViewModelFactory
  class file for dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory not found
  Consult the following stack trace for details.
cannot access DefaultActivityViewModelFactory

 

해결방법은 @ViewModelInject 어노테이션이 deprecated되었기에  @HiltViewModel 변경하면 해결

You can find more details in the Dagger 2.34 release notes, and I've just updated the release notes with a section to help migration from @ViewModelInject to @HiltViewModel.

 

Migration steps:

Users of @ViewModelInject can migrate to @HiltViewModel which was added in Dagger 2.31.

  1. Add @HiltViewModel annotation to the class
  2. Replace the @ViewModelInject annotation on the constructor with @Inject.
  3. Remove @Assisted from the SavedStateHandle constructor parameter, if it exists
  4. Remove the old androidx.hilt:hilt-lifecycle-viewmodel dependency from your build.gradle file

 

 

Comments