Skip to content

@ViewModelInject has deprecated #12

@kentcheung2000

Description

@kentcheung2000

Hi,

@ViewModelInject has deprecated. I change to the following and I still got an error.

"java.lang.RuntimeException: Cannot create an instance of class com.example.room_test.ui.tasks.TasksViewModel"

Is there a way I can solve the problem? Many thanks.

KC

@hiltviewmodel
class TasksViewModel @Inject constructor(
private val taskDao: TaskDao
) : ViewModel() {

val tasks = taskDao.getTasks().asLiveData()

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions