1

这是完整的错误: 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

}
4

1 回答 1

1

我通过更改 Kodein 的导入解决了这个问题,以前是:import org.kodein.di.kodein。

我把它改成这样:import org.kodein.di.android.kodein

于 2020-06-25T17:24:22.183 回答