java.lang.IllegalArgumentException при аутентификации с использованием firebase - PullRequest
0 голосов
/ 25 апреля 2019

Я делаю приложение, похожее на WhatsApp (следуя инструкциям). Он падает, когда я нажимаю кнопку отправить код . я подтвердил это, попробовав / поймав, мой номер телефона не работает, или с ним проблема

java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential 
without either verificationProof, sessionInfo, ortemprary proof.

Что я подтвердил / попробовал: оба вида деятельности объявлены в манифесте , присвоенный идентификатор макет , инициализированный относительный аргумент, В папке libs проекта ничего нет, замена инициализация с макетом, Попробовал этот код, чтобы получить значение:

    String.valueOf(phoneNumberEdt)

Я сделал все, что мог, согласно своему уровню

public class MainActivity extends AppCompatActivity {
    private EditText phoneNumberEdt, verificationcodeEdt;
    Button sendCodeButton;

private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBacks;

String mVerificationId = "0";

//private PhoneAuthProvider.ForceResendingToken mResendToken;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    phoneNumberEdt = (EditText) findViewById(R.id.phonenumber_edt);
    verificationcodeEdt = (EditText) 
findViewById(R.id.verificationcode_edt);
    sendCodeButton = (Button) findViewById(R.id.sendcode_btn);

    FirebaseApp.initializeApp(this);

    userIsLoggedIn();
    phoneNumberEdt.setText("03026989523");
    sendCodeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //try{
            if(mVerificationId != null)
                verifyPhoneNumberWithCode();
            else
                startPhoneNumberVerification();
            /*}catch (Exception e){
                Toast toast = Toast.makeText(getApplicationContext(),  
"Verification Code is wrong, try again", Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER,0,0);
                toast.show();
            }*/


            mCallBacks = new 
PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
                @Override
                public void onVerificationCompleted(PhoneAuthCredential 
phoneAuthCredential) {

                    signInWithPhoneAuthCredential(phoneAuthCredential);
                }

                @Override
                public void onVerificationFailed(FirebaseException e) {}

                @Override
                public void onCodeSent(String VerificationId, 
PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                    super.onCodeSent(VerificationId, forceResendingToken);
                     mVerificationId = VerificationId;
                     sendCodeButton.setText("Verify Code");
                }

            };
        }
    });
 }

Точки ошибки здесь

private void startPhoneNumberVerification() {

    PhoneAuthProvider.getInstance().verifyPhoneNumber(

phoneNumberEdt.getText().toString(),//String.valueOf(phoneNumberEdt)
             60,
            TimeUnit.SECONDS,
            this,
            mCallBacks);
 }

Остальные функции

private void verifyPhoneNumberWithCode(){
      PhoneAuthCredential credential = 
PhoneAuthProvider.getCredential(mVerificationId, 
verificationcodeEdt.getText().toString());
    signInWithPhoneAuthCredential(credential);
}

private void signInWithPhoneAuthCredential(PhoneAuthCredential 
phoneAuthCredential) {



FirebaseAuth.getInstance().signInWithCredential(phoneAuthCredential).
addOnComp leteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
                 if(task.isSuccessful())
                     userIsLoggedIn();
        }
    });

 }

 private void userIsLoggedIn() {

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if(user != null) {
        startActivity(new 
  Intent(getApplicationContext(),MainPageActivity.class));
        finish();
        return;
    }

  }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...