I'm currently working on my first project, so I'm sorry if it sounds like a stupid question.
I'm having trouble with a piece of code that should attempt to create a Firebase acccount with the email and password provided in the text boxes in the UI when you click a button. Instead, whenever I click that button, the app crashes with the error: java.lang.IllegalArgumentException: Given String is empty or null.
Code:
//Create new User
var email = emailID.text.toString().trim()
var pwd = passwordID.text.toString().trim()
create_acc_button.setOnClickListener{
mAuth!!.createUserWithEmailAndPassword(email,
pwd).addOnCompleteListener(this
) { task: Task<AuthResult> ->
if (task.isSuccessful){
var user:FirebaseUser = mAuth!!.currentUser!!
Log.d("User", user.email.toString())
}else{
Log.d("Error:", task.toString())
}
}
}
Logcat:
java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.zzbq.zzgm(Unknown Source:10)
at com.google.firebase.auth.FirebaseAuth.createUserWithEmailAndPassword(Unknown Source:0)
at com.example.david.mykotlinfirebaseintro.MainActivity$onCreate$1.onClick(MainActivity.kt:37)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)