Android - Error en firebaseAuth.createUserWithEmailAndPassword

 
Vista:
sin imagen de perfil

Error en firebaseAuth.createUserWithEmailAndPassword

Publicado por Santiago (2 intervenciones) el 15/11/2022 15:49:42
Buenos dias! estoy iniciando mis primeras lineas en programacion kotlin e intentando hacer un login via firebase (en el momento de registrar el usuario) la aplicacion "da un error que no puedo caputar" y responde con un popup "unfortunaly, "yourAPP" has stopped"

firebase esta sincronizado con la app y falla puntualmente al momento de llamar al registro, el correo no esta utilizado y no se por donde mirar. intente depurar la app pero al momento de hacer el registro, se haltea y no muestra mensaje



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import androidx.appcompat.content.res.AppCompatResources
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
 
 
 
 
class RegisterFragment : Fragment() {
    // TODO: Rename and change types of parameters
    private var param1: String? = null
    private var param2: String? = null
    private lateinit var email: EditText
    private lateinit var password: EditText
    private lateinit var confirmPassword: EditText
    private lateinit var firebaseAuth: FirebaseAuth
 
 
 
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        val view =  inflater.inflate(R.layout.fragment_register, container, false)
 
        email = view.findViewById(R.id.reg_Email)
        password= view.findViewById(R.id.reg_password)
        confirmPassword = view.findViewById(R.id.reg_confirm_password)
        firebaseAuth = Firebase.auth
 
        view.findViewById<Button>(R.id.LoginButton_reg).setOnClickListener {
            val navRegister = activity as FragmentNavigation
            navRegister.navigateFrag(LoginFragment(),false)
        }
 
        view.findViewById<Button>(R.id.RegisterButton_reg).setOnClickListener {
 
 
            if (validateData())  {
                try {
                    firebaseAuth.createUserWithEmailAndPassword(
                        email.text.toString(),password.text.toString()
                    )
.addOnCompleteListener { task -> //ERROR ACA!!!
                            if (task.isComplete) {
                                Toast.makeText(
                                    context,
                                    "Registrado Correctamente",
                                    Toast.LENGTH_SHORT
                                ).show()
                            } else {
                                Toast.makeText(context, task.exception?.message, Toast.LENGTH_SHORT)
                                    .show()
                            }
                        }
                }
                catch (e : Exception) {
                    Toast.makeText(context, e.message, Toast.LENGTH_SHORT)
                        .show()
                }
            }
        }
 
        return view
    }
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Error en firebaseAuth.createUserWithEmailAndPassword

Publicado por Abraham (1 intervención) el 16/11/2022 00:51:01
No estoy muy seguro, pero quizas sea este el problema:

Toast.makeText(context,"Registrado Correctamente",Toast.LENGTH_SHORT).show()

quizas deberias cambiarlo por esto:

no se si esta como requireActivity() o
Toast.makeText(requireActivity(),"Registrado Correctamente",Toast.LENGTH_SHORT).show()

como getActivity()
Toast.makeText(getActivity(),"Registrado Correctamente",Toast.LENGTH_SHORT).show()

intenta cambiar ese, quizas te pida usar ?.let, investiga sobre eso en ccaso de que te lo pida, saludos...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Error en firebaseAuth.createUserWithEmailAndPassword

Publicado por Santiago (2 intervenciones) el 16/11/2022 21:49:20
Gracias por la respuesta.
lamentablemente el error se presenta en el

1
createUserWithEmailAndPassword

probe con lo que me comentas, probe sin ningun tipo de mensajeria y hasta sin que me importe el resultado.

cuando invoca ese metodo, la app se cierra
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar