Alex Stillo
Alex Stillo

Reputation: 73

Firebase Error logging in with Google. 12501 null

No clue why this is happening. keep getting this error

Error logging in with Google. 12501 null

also this one.

W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.

Code:

package com.workoutwager.workoutwager;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.ui.ResultCodes;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;

import java.util.Arrays;

public class MainActivity extends AppCompatActivity {

    private FirebaseAuth mFirebaseAuth;
    public static final int RC_SIGN_IN = 1;
    private FirebaseAuth.AuthStateListener mAuthStateListener;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mFirebaseAuth= FirebaseAuth.getInstance();
        mAuthStateListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser user = firebaseAuth.getCurrentUser();
                if (user != null){
                    //signed in
                    Intent intent = new Intent(MainActivity.this, LoginSuccess.class);
                    startActivity(intent);


                }
                else{
                    //signed out

                    startActivityForResult(
                            AuthUI.getInstance()
                                    .createSignInIntentBuilder()
                                    .setProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                            new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                            new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
                                    .setIsSmartLockEnabled(false)
                                    .setLogo(R.drawable.logo)
                                    .build(),
                            RC_SIGN_IN);
                }
            }
        };

    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            // user is signed in!
            startActivity(new Intent(this, LoginSuccess.class));
            finish();
            return;
        }

        // Sign in canceled
        if (resultCode == RESULT_CANCELED) {
            startActivity(new Intent(this, MainActivity.class));
            return;
        }

        // No network
        if (resultCode == ResultCodes.RESULT_NO_NETWORK) {
            Toast.makeText(MainActivity.this, "You are not connected", Toast.LENGTH_LONG).show();
            return;
        }

        // User is not signed in. Maybe just wait for the user to press
        // "sign in" again, or show a message.
    }
    @Override
    protected void onPause(){
        super.onPause();
        mFirebaseAuth.removeAuthStateListener(mAuthStateListener);

    }
    @Override
    protected void onResume(){
        super.onResume();
        mFirebaseAuth.addAuthStateListener(mAuthStateListener);
    }
}

Gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.workoutwager.workoutwager"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.google.firebase:firebase-database:9.8.0'
    compile 'com.google.firebase:firebase-auth:9.6.1'
    compile 'com.firebaseui:firebase-ui-auth:1.0.0'
    testCompile 'junit:junit:4.12'
}

Upvotes: 6

Views: 2256

Answers (5)

Ashraf Sarhan
Ashraf Sarhan

Reputation: 1687

Upvotes: 0

Marius Kohmann
Marius Kohmann

Reputation: 721

I had the issue: Error logging in with Google. 10 null and found out that i mistakenly had opted to use the google play App Signing. The solution was then to copy the SHA-1 found in the google play console and enter this value into the firebase project settings.

Upvotes: 2

r4m
r4m

Reputation: 491

I solved the problem in Firebase adding the SHA1 fingerprints in the Project Settings as it is required by Google login:

To set up Google sign-in for your Android apps, you need to add the SHA1 fingerprint for each app on your Project Settings.

To get both the release and debug certificates follow the Google APIs authentication guide

Upvotes: 5

Bob Snyder
Bob Snyder

Reputation: 38289

This statement MUST go at the bottom of your app/build.gradle file:

apply plugin: 'com.google.gms.google-services'

Like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.google.firebase:firebase-database:9.8.0'
    compile 'com.google.firebase:firebase-auth:9.6.1'
    compile 'com.firebaseui:firebase-ui-auth:1.0.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

Also, as mentioned in @anfuca's answer, it is important to use consistent versions of the Firebase libraries. In addition, use a compatible version of firebase-ui-auth, as listed in the table at the Firebase UI page. Also note at that page that firebase-ui-auth has a transistive dependency on firebase-auth. You do not need to include firebase-auth in your dependencies.

My experience has been that the warning below is harmless. I see it in my logs during and after succussful auth actions:

W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found

Upvotes: 0

Anfuca
Anfuca

Reputation: 1329

About the module error... Have you checked the prerequisites?

  • A device running Android 2.3 (Gingerbread) or newer, and Google Play services 10.0.0 or newer

  • The Google Repository from the Android SDK Manager

  • Android Studio 1.5 or higher

Try to update in gradle these and let's see if it works:

  • com.google.firebase:firebase-database:10.0.0
  • com.google.firebase:firebase-auth:10.0.0

Upvotes: 0

Related Questions