gpt4 book ai didi

android - 只有安全或非 null asserted kotlin 消息

转载 作者:行者123 更新时间:2023-11-29 22:55:14 25 4
gpt4 key购买 nike

我正在尝试在我的手机上运行一个应用程序,但我的项目一直遇到这个问题请帮助我解决这个问题谢谢Only safe or non null asserted calls are allowed on a nullable receiver type of arraylis

register_btn.setOnClickListener { val email = 
email_registersscreen.text.toString()
val password = password_registerscreeb.text.toString()

Log.d("MainActiviy", "Email is:" + email)
Log.d("MainActivity", "Password:$password")

//Firebase Authentication user with email and password

FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password)
.addOnCompleteListener {
if (!it.isSuccessful) return@addOnCompleteListener

// else it successful
Log.d("Main", "successfully created user with uid:
${it.result.user.uid}")

}
}

最佳答案

此问题与 Kotlin 中的空安全有关。因为我真的看不到你的代码中的 arrayList 在哪里,我假设你有错误${it.result.user.uid} 它应该类似于 ${it.result?.user?.uid}

您可以在这里阅读更多相关信息:https://kotlinlang.org/docs/reference/null-safety.html

关于android - 只有安全或非 null asserted kotlin 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57496913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com