Classifier 'AuthResult' does not have a companion object, and thus must be initialized here

Hello All,
I am facing a bit of a problem on kotlin android.
I have a problem in which this warning come up : Classifier 'AuthResult' does not have a companion object, and thus must be initialized here, when I Build-> Make Project. I have placed initialization of uAuth already before function fun() below as uAuth=FirebaseAuth.getInstance() of which the text code is colored in red. See code below. But the warning still comes out. Can someone help me is it error on putting initialization at the wrong place? Or am I missing some declaration. Your most uergent help is greatly appreciated. The language below is kotlin android. Initially the code was written in javascript. And then I convert it to kotlin android using Android Studion.

Thanks and Best Regards
Ahmad Rodzaidi Bin Ahmad Faiz

The below is the code of my RegisterActivity

JavaScript:
package com.example.shoponlinenicheteck

import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.annotation.NonNull
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.tasks.OnCompleteListener
import com.google.android.material.textfield.TextInputLayout
import com.google.firebase.auth.AuthResult
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.database.FirebaseDatabase
import org.w3c.dom.Text

class RegisterActivity : AppCompatActivity() {
    var ufirstname: EditText? = null
    var ulastname: EditText? = null
    var uemail: EditText? = null
    var upassword: EditText? = null
    var uconfpassword: EditText? = null
    var ucontactno: EditText? = null
    var btnRegister: Button? = null
    var userFirstNameWrapper: TextInputLayout? = null
    var userLastNameWrapper: TextInputLayout? = null
    var userEmailWrapper: TextInputLayout? = null
    var userPasswordWrapper: TextInputLayout? = null
    var userConfPasswordWrapper: TextInputLayout? = null
    var userContactNoWrapper: TextInputLayout? = null
    private var uAuth: FirebaseAuth? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_register)

        val ufirstname = findViewById<View>(R.id.userFirstName)
        val ulastname = findViewById<View>(R.id.userLastName)
        val uemail = findViewById<View>(R.id.userEmailAddress)
        val upassword = findViewById<View>(R.id.userPassword)
        val uconfpassword = findViewById<View>(R.id.userConfPassword)
        val ucontactno = findViewById<View>(R.id.userContactNumber)

        val userFirstNameWrapper = findViewById<TextInputLayout>(R.id.userFirstNameWrapper)
        val userLastNameWrapper = findViewById<TextInputLayout>(R.id.userlastNameWrapper)
        val userEmailWrapper = findViewById<TextInputLayout>(R.id.userEmailWrapper)
        val userPasswordWrapper = findViewById<TextInputLayout>(R.id.userPasswordWrapper)
        val userConfPasswordWrapper = findViewById<TextInputLayout>(R.id.userConfPasswordWrapper)
        val userContactNoWrapper = findViewById<TextInputLayout>(R.id.userContactNoWrapper)

        val btnRegister=findViewById<Button>(R.id.btnRegister)

    }

    init {
        var onClick: Unit


            run {
                if (uAuth!!.currentUser != null) {
                    //User is Logged in and can redirect to another activity.

                    val firstname = ufirstname!!.text.toString().trim { it <= ' ' }
                    val lastname = ulastname!!.text.toString().trim { it <= ' ' }
                    val email = uemail!!.text.toString().trim { it <= ' ' }
                    val password = upassword!!.text.toString().trim { it <= ' ' }
                    val confpassword = uconfpassword!!.text.toString().trim { it <= ' ' }
                    val contactno = ucontactno!!.text.toString().trim { it <= ' ' }
                    if (firstname.isEmpty()) {
                        userFirstNameWrapper!!.error = "Enter First Name"
                        userFirstNameWrapper!!.requestFocus()

                    }
                    if (lastname.isEmpty()) {
                        userLastNameWrapper!!.error = "Enter Last Name"
                        userLastNameWrapper!!.requestFocus()

                    }
                    if (email.isEmpty()) {
                        userEmailWrapper!!.error = "Enter Email"
                        userEmailWrapper!!.requestFocus()

                    }
                    if (password.isEmpty()) {
                        userPasswordWrapper!!.error = "Enter Password"
                        userPasswordWrapper!!.requestFocus()

                    }
                    if (confpassword.isEmpty()) {
                        userConfPasswordWrapper!!.error = "Enter Confirm Password"
                        userConfPasswordWrapper!!.requestFocus()

                    }
                    if (password != confpassword) {
                        userConfPasswordWrapper!!.error = "Password didn't match"
                        userConfPasswordWrapper!!.requestFocus()

                    }
                    if (contactno.isEmpty()) {
                        userContactNoWrapper!!.error = "Enter Contact No"
                        userContactNoWrapper!!.requestFocus()

                    }

                    [COLOR=#8000ff]uAuth=FirebaseAuth.getInstance()[/COLOR]

                    fun () {
                        onStart()
                        super.onStart()
                        //Check if user is signed in (non-null) and update UI accordingly
                        val user = User(firstname, lastname, email, contactno)
                        FirebaseDatabase.getInstance().getReference("Users")
                            .child(FirebaseAuth.getInstance().currentUser!!.uid)

                        var onComplete: Unit

                    }
                    if (AuthResult)
                    uAuth= FirebaseAuth.getInstance()
                    uAuth!!.createUserWithEmailAndPassword(email, password)
                        .addOnCompleteListener(OnCompleteListener { AuthResult})
                    var onComplete: Unit

                    var task: NonNull; Task<AuthResult?>
                    (
                            if (task.isSuccessful()) {
                                val user = User(firstname, lastname, email, contactno)
                                FirebaseDatabase.getInstance().getReference("Users")
                                    .child(FirebaseAuth.getInstance().currentUser!!.uid)
                                    .setValue(user)
                                    .addOnCompleteListener(OnCompleteListener<Unit>())
                                var onComplete: Unit
                                NonNull
                                var task: Task<Void?>
                                (
                                        if (task.IsSuccessful()) Toast.makeText(
                                            this@RegisterActivity,
                                            "User created successfully.",
                                            Toast.LENGTH_LONG.show()
                                        ) else
                                            Toast.makeText(
                                                this@RegisterActivity,
                                                task.getException().getMessage(),
                                                Toast.LENGTH_LONG.show()
                                            )
                                        )
                            } else Toast.makeText(
                                this@RegisterActivity,
                                task.getException().getMessage(),
                                Toast.LENGTH_LONG.show()
                            )
                            )

                }


            }




    }

}
 
Top