None of the following functions can be called with the arguments supplied: public constructor ViewM

在这里插入图片描述

android studio的报错提示:

e: D:\AndroidSource\RoomDemo\app\src\main\java\com\bignerdranch\android\MainActivity.kt: (42, 50): None of the following functions can be called with the arguments supplied: 
public constructor ViewModelProvider(p0: ViewModelStore, p1: ViewModelProvider.Factory) defined in androidx.lifecycle.ViewModelProvider
public constructor ViewModelProvider(p0: ViewModelStoreOwner, p1: ViewModelProvider.Factory) defined in androidx.lifecycle.ViewModelProvider

解决问题:
ViewModelLifeCycle的一个组件库,所以只需要添加LifeCycle库的依赖即可

implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"

猜你喜欢

转载自blog.csdn.net/qq_35091074/article/details/134805814