我在我的Android应用程序中使用了fire-base身份验证,因此当我按下按钮登录时,文本字段的电子邮件和密码为空,我的应用程序崩溃。我使用了fire-base version 10.0.1,这是我的代码:
button_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String email_et = mail_login_et.getText().toString();
final String password_et = pass_login_et.getText().toString();
mAuth.signInWithEmailAndPassword(email_et, password_et)
.addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("LOGINACT", "signInWithEmail:onComplete:" + task.isSuccessful());
if (task.isSuccessful()) {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
} else {
// startActivity(new Intent(LoginActivity.this, MainActivity.class));*
Log.w("LOGINACT", "signInWithEmail:failed", task.getException());
}
}
});
}
});
这是错误日志:
E/UncaughtException: java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.zzac.zzdv(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.signInWithEmailAndPassword(Unknown Source)
at com.esprit.couverture4g.activities.LoginActivity$1.onClick(LoginActivity.java:83)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
W/art: Suspending all threads took: 25.358ms
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.esprit.couverture4g, PID: 3127
java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.zzac.zzdv(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.signInWithEmailAndPassword(Unknown Source)
at com.esprit.couverture4g.activities.LoginActivity$1.onClick(LoginActivity.java:83)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)