Though I controlled it with an if statement I'm getting ''Given string empty or null'' error and my app is closing.
fun kayitOl ( view : View) {
val email =findViewById<EditText>(R.id.emailText).text
val password = findViewById<EditText>(R.id.passwordText).text
if (email != null && password != null ) {
auth.createUserWithEmailAndPassword(email.toString(), password.toString())
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
val intent = Intent(this, haber_akisi::class.java)
startActivity(intent)
finish()
}
}.addOnFailureListener { exception ->
Toast.makeText(this, exception.localizedMessage, Toast.LENGTH_LONG).show()
}
}else {
Toast.makeText(this,"Lütfen E-mail ve Password alanlarını doldurunuz",Toast.LENGTH_LONG).show()
}
}
CodePudding user response:
You check just for null, but not for empty string ""
You can change your checking with email.isEmpty() or better email.isBlank() for checking strings like " "
CodePudding user response:
I found that in logcat sorry for my awkwardness it says
auth.createUserWithEmailAndPassword(email.toString(), password.toString()) line is incorrect here is my logcat.
Caused by: java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.Preconditions.checkNotEmpty(com.google.android.gms:play-services-basement@@17.1.0:5)
at com.google.firebase.auth.FirebaseAuth.signInWithEmailAndPassword(com.google.firebase:firebase-auth@@21.0.1:1)
at com.example.instagramclone.MainActivity.girisYap(MainActivity.kt:43)
