我的应用程序在验证手机身份验证时崩溃,成功接收到短信但单击验证按钮时崩溃,并非所有设备,Play 商店中 20% 的设备都崩溃。这是 Play 管理中心的日志。
java.lang.IllegalArgumentException:
at com.google.android.gms.common.internal.Preconditions.checkArgument (Preconditions.java:9)
at com.google.firebase.auth.PhoneAuthCredential.<init> (PhoneAuthCredential.java:60)
at com.google.firebase.auth.PhoneAuthCredential.zza (PhoneAuthCredential.java:10)
at com.google.firebase.auth.PhoneAuthProvider.getCredential (PhoneAuthProvider.java:2)
at com.udaan.recstudentportalV2.VerifyMobile.matchOtp (VerifyMobile.java:2)
at com.udaan.recstudentportalV2.VerifyMobile.access$200 (VerifyMobile.java:2)
at com.udaan.recstudentportalV2.VerifyMobile$3.onClick (VerifyMobile.java:2)
at android.view.View.performClick (View.java:7862)
at android.widget.TextView.performClick (TextView.java:15004)
at com.google.android.material.button.MaterialButton.performClick (MaterialButton.java:3)
at android.view.View.performClickInternal (View.java:7831)
at android.view.View.access$3600 (View.java:879)
at android.view.View$PerformClick.run (View.java:29359)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:237)
at android.app.ActivityThread.main (ActivityThread.java:8167)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)
如有任何帮助,我们将不胜感激。
答案 0 :(得分:0)
问题已通过重新创建解决。当用户在发送 OTP 之前单击验证按钮时会发生这种情况。在调用 getCredential() 方法之前初步检查是否发送了 OTP 将有助于纠正此问题。
答案 1 :(得分:0)
以下方式我用firebase发送otp它完美地工作
private PhoneAuthProvider.OnVerificationStateChangedCallbacks
verificationCallbacks;
//On Create
Send_Number_tofirebase(phoneNumber);
public void Send_Number_tofirebase(String phoneNumber){
setUpVerificatonCallbacks();
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
this,
verificationCallbacks);
}
private void setUpVerificatonCallbacks() {
Functions.Show_loader(this,false,true);
verificationCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
Functions.cancel_loader();
signInWithPhoneAuthCredential(credential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
Functions.cancel_loader();
Log.d("response",e.toString());
Toast.makeText(Login_Phone_A.this, "Enter Correct Number.", Toast.LENGTH_SHORT).show();
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
} else if (e instanceof FirebaseTooManyRequestsException) {
// SMS quota exceeded
}
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken token) {
Functions.cancel_loader();
phoneVerificationId = verificationId;
resendToken = token;
sendtotxt.setText("Send to ( "+phoneNumber+" )");
viewFlipper.setInAnimation(Login_Phone_A.this, R.anim.in_from_right);
viewFlipper.setOutAnimation(Login_Phone_A.this, R.anim.out_to_left);
viewFlipper.setDisplayedChild(1);
}
};
}
听到验证按钮按下
public void verifyCode(View view) {
String code=""+digit1.getText().toString()+digit2.getText().toString()+digit3.getText().toString()+digit4.getText().toString()+digit5.getText().toString()+digit6.getText().toString();
if(!code.equals("")){
Functions.Show_loader(this,false,true);
PhoneAuthCredential credential =
PhoneAuthProvider.getCredential(phoneVerificationId, code);
signInWithPhoneAuthCredential(credential);
}else {
Toast.makeText(this, "Enter the Correct varification Code", Toast.LENGTH_SHORT).show();
}