Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewModel has no zero argument constructor #29

Closed
Lumberjack100 opened this issue May 30, 2022 · 2 comments
Closed

ViewModel has no zero argument constructor #29

Lumberjack100 opened this issue May 30, 2022 · 2 comments

Comments

@Lumberjack100
Copy link

使用 getApplicationScopeViewModel(Class modelClass) 方法初始化 ViewModel 时,如果传入的是一个 AndroidViewModel,会报
java.lang.Class<com.kunminx.puremusic.domain.message.SharedViewModel> has no zero argument constructor

想请教下 AndroidViewModel 怎么使用 Application context 初始化?

@Lumberjack100
Copy link
Author

补充截图说明

image

将 ViewModel 换成 AndroidViewModel,运行程序会崩溃

@Lumberjack100
Copy link
Author

Bug 修复了,需要使用两个参数的构造函数,必须传递 Factory 实例参数

image

@KunMinX KunMinX closed this as completed May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants