Combining Facebook and Google auth for Firebase Android
<p><strong>Background</strong></p>

<p>Hello, I'm new with Firebase for Android and I'm trying to implement the Facebook and Google auth/login for the first time. I followed these two tutorials for the corresponding authentication:</p>

<ul>
<li>http:// firebase.google.com/docs/auth/android/google-signin </li>
<li>http:// firebase.google.com/docs/auth/android/facebook-login</li>
</ul>

<p>Separately, the <code>FacebookSignInActivity</code> and <code>GoogleSignInActivity</code> are working as they should.</p>

<p><strong>Problem</strong></p>

<p>The problem is that I'm trying to use the Google and Facebook auth in the same activity, but it won't work. Like so:</p>

<p><img src="https://i.stack.imgur.com/4Dgtr.png" alt="result layout image"></p>

<p><strong>What I did</strong></p>

<p>I tried to keep the <code>FacebookSignInActivity</code> separate from the <code>GoogleSignInActivity</code> by letting them extend a <code>MainActivity</code> and set the layout in there.</p>

<p>But I think I'm supposed to merge the two into one. So I tried that but I'm getting a weird nullpointer exception:</p>

<pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.firebase.auth.FirebaseAuth.addAuthStateListener(com.google.firebase.auth.FirebaseAuth$AuthStateListener)' on a null object reference
</code></pre>

<p>I don't know why the object is null in the <code>onCreate</code> because I've copied the same code from the other two activities which are working:</p>

<pre><code> mAuth = FirebaseAuth.getInstance();

 mAuthListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser user = firebaseAuth.getCurrentUser();
                if (user != null) {
                    // User is signed in
                    Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
                } else {
                    // User is signed out
                    Log.d(TAG, "onAuthStateChanged:signed_out");
                }
                // [START_EXCLUDE]
                updateUI(user);
                // [END_EXCLUDE]
            }
        };
</code></pre>

<p>I'm not even sure if I'm even supposed to merge the two into one activity. I've also checked these links:</p>

<ul>
<li><a href="https://firebase.google.com/docs/auth/android/account-linking" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/android/account-linking</a></li>
<li><a href="https://stackoverflow.com/questions/37768529/how-to-link-multiple-auth-providers-to-an-firebase-account">How to Link Multiple Auth Providers to an Firebase Account?</a></li>
</ul>

<p>But it looks like that is something else from what I'm trying to do. If someone could help point me in the right direction, it would be gladly appreciated.</p>