I have implemented the Google Sign In with Firebase for an Android Application. I have followed the official guide ( https://firebase.google.com/docs/auth/android/google-signin ), I have updated the settings with the debug and release HA-1 fingerprint and I keep receiving the same error. The debug version works fine but the release version does not work.
I run the command
keytool -exportcert -list -v -alias {my-key-name} -keystore {path-to-production-keystore}
for my production keystore, the one I use to sign my .apk when deploying it, I have added the sha1 to the Applications's Firebase Settings and I still receive the error.
This is the class that makes the Authentication
class FirebaseAuthenticator(private val activity: AppCompatActivity, private val onAuthCompleteListener: OnAuthCompleteListener): Authentication, FacebookCallback<LoginResult>, GoogleApiClient.OnConnectionFailedListener {
private val mGoogleApiClient: GoogleApiClient
private val callbackManager: CallbackManager = CallbackManager.Factory.create()
override var isPerformingLogin: Boolean = false
private val firebaseAuthCompleteListener = object: OnCompleteListener<AuthResult> {
override fun onComplete(task: Task<AuthResult>) {
if (task.isSuccessful) {
val user = FirebaseAuth.getInstance().currentUser!!
FirebaseDataAccess._instance.saveUser(FirebaseMapper.mapToUser(user), { exc, _ ->
isPerformingLogin = false
when(exc) {
null -> {
onAuthCompleteListener.onAuthComplete(null, FirebaseSession._instance)
}
else -> {
FirebaseSession._instance.signOut()
onAuthCompleteListener.onAuthComplete(exc, null)
}
}
})
} else {
isPerformingLogin = false
onAuthCompleteListener.onAuthComplete(task.exception, null)
}
}
}
init {
LoginManager.getInstance().registerCallback(callbackManager, this)
val webId = activity.getString(R.string.default_web_client_id)
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(webId)
.requestEmail()
.build()
mGoogleApiClient = GoogleApiClient.Builder(activity)
.enableAutoManage(activity /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build()
}
override fun loginWithFacebook() {
isPerformingLogin = true
LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList("public_profile", "user_friends", "email"))
}
override fun loginWithGoogle() {
isPerformingLogin = true
val signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient)
activity.startActivityForResult(signInIntent, RC_SIGN_IN)
}
override fun loginWithEmail(email: String, password: String) {
isPerformingLogin = true
FirebaseAuth.getInstance().signInWithEmailAndPassword(email, password)
.addOnCompleteListener(activity, firebaseAuthCompleteListener)
}
override fun onSuccess(loginResult: LoginResult) {
val credential = FacebookAuthProvider.getCredential(loginResult.accessToken.token)
authWithCredential(credential)
}
override fun onError(error: FacebookException) {
isPerformingLogin = false
onAuthCompleteListener.onAuthComplete(error, null)
}
override fun onCancel() {
isPerformingLogin = false
onAuthCompleteListener.onAuthComplete(null, null)
}
override fun onConnectionFailed(connResult: ConnectionResult) {
isPerformingLogin = false
onAuthCompleteListener.onAuthComplete(Exception(connResult.errorMessage), null);
}
override fun onActivityResultCallback(requestCode: Int, resultCode: Int, data: Intent) {
callbackManager.onActivityResult(requestCode, resultCode, data)
if (requestCode == RC_SIGN_IN) {
val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
if (result.isSuccess) {
// Google Sign In was successful, authenticate with Firebase
val credential = GoogleAuthProvider.getCredential(result.signInAccount!!.idToken, null)
authWithCredential(credential)
} else {
isPerformingLogin = false
onAuthCompleteListener.onAuthComplete(Exception(result.status.toString()), null);
}
}
}
private fun authWithCredential(credential: AuthCredential) {
FirebaseAuth.getInstance().signInWithCredential(credential)
.addOnCompleteListener(activity, firebaseAuthCompleteListener)
}
companion object {
private val RC_SIGN_IN = 9001
}
}
this is my my app's build file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
android {
signingConfigs {
p2s_keystore {
keyAlias 'myalias'
keyPassword 'myKeyPassword'
storeFile file('/path to my keystore')
storePassword 'myStorePassword'
}
}
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.app.play2sell"
minSdkVersion 16
targetSdkVersion 25
versionCode 8
versionName "1.2.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
signingConfig signingConfigs.p2s_keystore
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.p2s_keystore
debuggable true
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.firebase:firebase-database:11.2.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.android.gms:play-services-auth:11.2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
// FIREBASE
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
repositories {
mavenCentral()
}
I am sure I have the correct SHA1 of my keystore signing certificate on the console. I have checked it hundreds of times. I am also sure I am signing my application with the keystore I used to generate the SHA1 saved on the Firebase Console.
I have also downloaded to my android project the latest version of the google-services.json file.
Does anyone have any idea of why I keep receiving the DEVELOPER_ERROR in the status code of my activity result when trying to login with Google.
Thanks in advance