title: App crashing while verifying OTP in Android Studio with firebase
body: <p>I was trying to build an OTP system in Android Studio and I came up with the code given below, however, the app is crashing every time I try to send OTP to my phone number. Here is the code:</p>
  <blockquote>
  <p>Signp3rdClass.java</p>
  </blockquote>
  <pre><code>public class Signup3rdClass extends AppCompatActivity {
  
      TextInputLayout phoneNumber;
      CountryCodePicker countryCodePicker;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
          setContentView(R.layout.activity_signup3rd_class);
  
          //Hooks
          countryCodePicker = findViewById(R.id.country_code_picker);
          phoneNumber = findViewById(R.id.signup_phone_number);
      }
  
      public void callVerifyOTPScreen(View view) {
  
          if (!validatePhoneNumber()) {
              return;
          }
  
          Intent intent = new Intent(getApplicationContext(), VerifyOTP.class);
  
          String _fullName = getIntent().getStringExtra(&quot;fullname&quot;);
          String _username = getIntent().getStringExtra(&quot;username&quot;);
          String _email = getIntent().getStringExtra(&quot;email&quot;);
          String _password = getIntent().getStringExtra(&quot;password&quot;);
          String _gender = getIntent().getStringExtra(&quot;gender&quot;);
          String _date = getIntent().getStringExtra(&quot;date&quot;);
  
          String _getUserPhoneNumber = phoneNumber.getEditText().getText().toString().trim();
          String _phoneNo = &quot;+&quot; + countryCodePicker.getFullNumber() + _getUserPhoneNumber;
  
          intent.putExtra(&quot;fullName&quot;, _fullName);
          intent.putExtra(&quot;username&quot;, _username);
          intent.putExtra(&quot;email&quot;, _email);
          intent.putExtra(&quot;password&quot;, _password);
          intent.putExtra(&quot;date&quot;, _date);
          intent.putExtra(&quot;gender&quot;, _gender);
          intent.putExtra(&quot;phoneNo&quot;, _phoneNo);
  
          startActivity(intent);
      }
  
      private boolean validatePhoneNumber() {
          String val = phoneNumber.getEditText().getText().toString().trim();
          String checkNo = &quot;[7-9][0-9]{9}&quot;;
  
          if (val.isEmpty()) {
              phoneNumber.setError(&quot;Enter valid Phone Number!&quot;);
              return false;
          } else if (!val.matches(checkNo)) {
              phoneNumber.setError(&quot;Enter valid Phone Number!&quot;);
              return false;
          } else {
              phoneNumber.setError(null);
              phoneNumber.setErrorEnabled(false);
              return true;
          }
      }
  }
  </code></pre>
  <blockquote>
  <p>Signup3rd.xml</p>
  </blockquote>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;ScrollView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  tools:context=&quot;.Common.LoginSingup.Signup3rdClass&quot;
  android:background=&quot;@color/offwhite&quot;&gt;
  
  &lt;LinearLayout
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:padding=&quot;30dp&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/signup_back_button&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:padding=&quot;5dp&quot;
          android:src=&quot;@drawable/back_btn&quot;
          android:transitionName=&quot;transition_back_btn&quot;/&gt;
  
      &lt;TextView
          android:id=&quot;@+id/create_account&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;20dp&quot;
          android:fontFamily=&quot;sans-serif-medium&quot;
          android:text=&quot;@string/create_account&quot;
          android:textAllCaps=&quot;true&quot;
          android:textColor=&quot;@color/black&quot;
          android:textSize=&quot;40sp&quot;
          android:transitionName=&quot;transition_title_text&quot;/&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;vertical&quot;
          android:layout_marginTop=&quot;40dp&quot;&gt;
  
  
          &lt;com.hbb20.CountryCodePicker
              android:id=&quot;@+id/country_code_picker&quot;
              android:layout_height=&quot;match_parent&quot;
              android:layout_width=&quot;match_parent&quot;
              app:ccp_autoDetectCountry=&quot;true&quot;
              app:ccp_showFlag=&quot;true&quot;
              app:ccp_showNameCode=&quot;true&quot;
              app:ccp_showFullName=&quot;true&quot;
              android:background=&quot;@drawable/black_border&quot;/&gt;
  
          &lt;com.google.android.material.textfield.TextInputLayout
              android:id=&quot;@+id/signup_phone_number&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              app:startIconDrawable=&quot;@drawable/field_phone_number_icon&quot;
              style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;
              app:hintTextColor=&quot;@color/black&quot;
              app:endIconMode=&quot;clear_text&quot;
              app:endIconTint=&quot;@color/black&quot;
              app:boxStrokeWidthFocused=&quot;2dp&quot;
              app:boxStrokeColor=&quot;@color/black&quot;&gt;
  
          &lt;com.google.android.material.textfield.TextInputEditText
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:hint=&quot;@string/enter_phone_no&quot;/&gt;
  
          &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;Button
          android:id=&quot;@+id/signup_next_btn&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;@string/otp_code_btn&quot;
          android:layout_marginTop=&quot;20dp&quot;
          android:onClick=&quot;callVerifyOTPScreen&quot;
          android:elevation=&quot;5dp&quot;
          android:background=&quot;@color/colorPrimaryDark&quot;
          android:textColor=&quot;@color/white&quot;
          android:fontFamily=&quot;@font/montserrat_regular&quot;
          android:textSize=&quot;20sp&quot;
          android:transitionName=&quot;transition_next_btn&quot;/&gt;
  
  
      &lt;Button
          android:id=&quot;@+id/signup_login_btn&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;@string/login&quot;
          android:layout_marginTop=&quot;20dp&quot;
          android:elevation=&quot;5dp&quot;
          android:background=&quot;@color/transparant&quot;
          android:fontFamily=&quot;@font/montserrat_regular&quot;
          android:textSize=&quot;20sp&quot;
          android:textColor=&quot;@color/black&quot;
          android:transitionName=&quot;transition_login_btn&quot;/&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is my OTP Verification Class:</p>
  <blockquote>
  <p>VerifyOTP.java</p>
  </blockquote>
  <pre><code>public class VerifyOTP extends AppCompatActivity {
  
  PinView pinFromUser;
  String codeBySystem;
  FirebaseAuth mAuth;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.activity_verify_o_t_p);
  
      pinFromUser = findViewById(R.id.pin_view);
  
      String _phoneNumber = getIntent().getStringExtra(&quot;phoneNo&quot;);
  
      mAuth = FirebaseAuth.getInstance();
  
      sendVerificationCodeToUser(_phoneNumber);
  }
  
  private void sendVerificationCodeToUser(String phoneNumber) {
  
      PhoneAuthOptions options =
              PhoneAuthOptions.newBuilder(mAuth)
                      .setPhoneNumber(phoneNumber)       // Phone number to verify
                      .setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
                      .setActivity(this)                 // Activity (for callback binding)
                      .setCallbacks(mCallbacks)          // OnVerificationStateChangedCallbacks
                      .build();
      PhoneAuthProvider.verifyPhoneNumber(options);
  }
  
  private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks =
          new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
  
              @Override
              public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                  super.onCodeSent(s, forceResendingToken);
                  codeBySystem = s;
              }
  
              @Override
              public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {
                  String code = phoneAuthCredential.getSmsCode();
                  if(code != null){
                      pinFromUser.setText(code);
                      verifyCode(code);
                  }
              }
  
              @Override
              public void onVerificationFailed(@NonNull FirebaseException e) {
                  Toast.makeText(VerifyOTP.this, e.getMessage(), Toast.LENGTH_SHORT).show();
              }
          };
  
  private void verifyCode(String code) {
      PhoneAuthCredential credential = PhoneAuthProvider.getCredential(codeBySystem, code);
      signInWithPhoneAuthCredential(credential);
  }
  
  
  private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
  
      mAuth.signInWithCredential(credential)
              .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                      if (task.isSuccessful()) {
  
                          Toast.makeText(VerifyOTP.this, &quot;Verification Completed!&quot;, Toast.LENGTH_SHORT).show();
  
                      } else {
  
                          if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
                              Toast.makeText(VerifyOTP.this, &quot;Verification failed! Please try again&quot;, Toast.LENGTH_LONG).show();
                          }
                      }
                  }
              });
  }
  </code></pre>
  <blockquote>
  <p>Logs:</p>
  </blockquote>
  <pre><code>E/CCP: getFullNumber: Could not parse number
  I/Timeline: Timeline: Activity_launch_request time:218578976
  
  W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@a4a9614
  
  E/zza: Problem retrieving SafetyNet Token: 7: 
  I/Timeline: Timeline: Activity_launch_request time:218581077
  W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@5459e2f
  W/xample.desikha: Accessing hidden method Lsun/misc/Unsafe;-&gt;getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
  
  E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.desikhao, PID: 19549
  java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
      at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92)
      at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79)
      at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88)
      at android.os.AsyncTask.finish(AsyncTask.java:755)
      at android.os.AsyncTask.access$900(AsyncTask.java:192)
      at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:224)
      at android.app.ActivityThread.main(ActivityThread.java:7562)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
   Caused by: java.lang.ClassNotFoundException: Didn't find class &quot;androidx.browser.customtabs.CustomTabsIntent$Builder&quot; on path: DexPathList[[zip file &quot;/data/app/com.example.desikhao-Z6Qez6I7lCc14bx6bjFINg==/base.apk&quot;],nativeLibraryDirectories=[/data/app/com.example.desikhao-Z6Qez6I7lCc14bx6bjFINg==/lib/arm64, /system/lib64, /system/product/lib64]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:230)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
      at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92) 
      at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79) 
      at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88) 
      at android.os.AsyncTask.finish(AsyncTask.java:755) 
      at android.os.AsyncTask.access$900(AsyncTask.java:192) 
      at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772) 
      at android.os.Handler.dispatchMessage(Handler.java:107) 
      at android.os.Looper.loop(Looper.java:224) 
      at android.app.ActivityThread.main(ActivityThread.java:7562) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
  </code></pre>
  <p>Please let me know what am I doing wrong here.</p>