9

I have a project using firebase and the firebase auth ui library. The problem is I can't sign in using Google sign-in, when I try it loads for a second or two and then just shows a toast message saying "Developer Error". I can sign in with email and password just fine. And this is only a problem on signed apks, when I am debugging Google, sign-in works fine.

In my proguard-rules.pro I have minifyEnabled set to false.

And I have added the SHA-1 to my firebase project and have downloaded the correct json file.

dependency block from app level build.gradle

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:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support:cardview-v7:26.0.2'
    compile 'com.google.firebase:firebase-database:11.4.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'com.firebaseui:firebase-ui-auth:3.1.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

here is my AuthStateListener

mAuthStateListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser user = firebaseAuth.getCurrentUser();
                if (user != null) {
                    signedInInitialized();
                } else {
                    signedOutCleanUp();
                    startActivityForResult(
                            AuthUI.getInstance()
                                    .createSignInIntentBuilder()
                                    .setTheme(R.style.FirebaseSignInTheme)
                                    .setIsSmartLockEnabled(false)
                                    .setAvailableProviders(
                                            Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                                new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()))
                                .build(),
                        RC_SIGN_IN);
                }
            }
        };

The logcat shows no error or anything. I would post the logcat when this happens but I don't know how to get the logcat from a signed apk cause this only happens on sign the apk.

I have tried to figure this out for days but seem to be making no head way.

Thanks

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
Trevor Wiebe
  • 113
  • 1
  • 6

4 Answers4

9

You have added the signature of the debug key in the console. But the signature of release key is different. Add the signature of release key that you used to sign the apk in the firebase console.

First generate key using following command:

keytool -list -v -keystore KEYSTORE_PATH -alias ALIAS_NAME

Then copy the SHA-1 checksum and go to:

Firebase Console > Your project > Settings of the app > Add Fingerprint

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
2

Google is getting more and more ugly, they're making simple things complicated. The problem is the third key,

1、the debug key

2、the release key

3、Google Play App signing key

You need THREE keys to figure out ONE Google SignIn.

Does facebook also need three keys? Maybe one day google will need 30 keys.

Jack Wilson
  • 6,065
  • 12
  • 29
  • 52
0

You have added Both key

  1. Your android debug key SHA-1

  2. Your signature of release key SHA-1

0

The easiest way to do this is with android studio: Tools -> Firebase -> Authentication -> Click on the small play button, and press on the Connect button in the first option. Android studio will do it for you, generate the SHA-1 key and add it your project.

Kőne Mátyás
  • 312
  • 1
  • 2
  • 14