这是完整的错误: e: C:\Users\HP\AndroidStudioProjects\MoneyManager\app\src\main\java\com\cruxrepublic\moneymanager\ui\auth\LoginActivity.kt: (22, 28):
Expression 'kodein ' 不能作为函数调用。未找到函数“invoke()”
这是错误中引用的代码块。我通常是依赖注入的新手,但我会很感激任何帮助
class LoginActivity() : AppCompatActivity(), AuthListener, KodeinAware {
override val kodein by kodein()
private val factory by instance<AuthViewModelFactory>()
private lateinit var authViewModel: AuthViewModel
private lateinit var binding: ActivityLoginBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding= DataBindingUtil.setContentView(this,R.layout.activity_login)
authViewModel = ViewModelProvider(this,factory).get(AuthViewModel::class.java)
binding.authViewModel = authViewModel
authViewModel.authListener = this
}