【问题标题】:PhoneCallbacks Firebase :: Class 'PhoneCallbacks' is not abstract and does not implementPhoneCallbacks Firebase :: Class 'PhoneCallbacks' 不是抽象的,也没有实现
【发布时间】:2021-12-15 23:06:51
【问题描述】:

好的,所以我从另一位开发人员那里得到了这段代码(我知道 PHP、Web 开发,但我对 android 和 firebase 没有那么经验)他给了我这段代码以及一些过时的 SDK 和库,所以我更新了它们,但现在是其中一个kotlin 文件不断抛出这个错误,我不知道如何解决它,任何人都可以帮忙

class PhoneCallbacks(private val listener : PhoneCallbacksListener) : PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

    interface PhoneCallbacksListener {
        fun onVerificationCompleted(credential: PhoneAuthCredential?)
        fun onVerificationFailed(exception: FirebaseException?)
        fun onCodeSent(
                verificationId: String?,
                token: PhoneAuthProvider.ForceResendingToken?
        )
    }

    override fun onVerificationCompleted(phoneAuthCredential: PhoneAuthCredential?) {
        listener.onVerificationCompleted(phoneAuthCredential)
    }

    override fun onVerificationFailed(exception: FirebaseException?) {
        listener.onVerificationFailed(exception)
    }

    override fun onCodeSent(verificationId: String?, token: PhoneAuthProvider.ForceResendingToken?) {
        listener.onCodeSent(verificationId,token)
    }
}

错误:

PhoneCallBacks.kt:(6, 1):“PhoneCallbacks”类不是抽象类,不实现抽象基类成员 public abstract fun onVerificationCompleted(p0: PhoneAuthCredential):在 com.google.firebase.auth.PhoneAuthProvider 中定义的单元.OnVerificationStateChangedCallbacks

【问题讨论】:

  • 您是否尝试按照错误消息中的说明进行操作?
  • 我的意思是,是的,但它只会引发更多错误
  • 嗨,兄弟,我真的很忙,我会检查一下,然后再向您报告。谢谢你的帮助,我希望你有一个美好的一天!

标签: android firebase kotlin firebase-authentication


【解决方案1】:

您已将 onVerificationCompleted 声明为:

override fun onVerificationCompleted(phoneAuthCredential: PhoneAuthCredential?) {

但实际的interfaceonVerificationCompleted 定义为非可选的,所以:

override fun onVerificationCompleted(phoneAuthCredential: PhoneAuthCredential) {

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多