4

After uploading app to google play, google phone authentication is not working. Below is the error I am getting in logcat.

This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console.

Most of the answers I have read on stack-overflow tell that "SHA1 key is different for signed apk. So you have two SHA1, one each for debug and release version. The SHA1 for release version can be obtained from keystore file."

These answers do not solve my problem. Here is what I have done so far.

I have added both debug and release SHA1 keys in google firebase console.

Downloaded the new google-services.json file and replaced in the projected folder with the old one.

Generated the signed apk from android studio.

If I manually install the apk in my phone both debug and release versions of apk work fine.

But if I upload the released version to google play for beta testing it gives me App validation failed error.

I have also confirmed that SHA1 are same in "App signing" in Google Play Console and Firebase Console.

Any help please.

here is build.gradle

plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "-----"
        minSdkVersion 15
        targetSdkVersion 27
        useLibrary 'org.apache.http.legacy'
        versionCode 7
        versionName "1.0"
        multiDexEnabled true
        manifestPlaceholders = [onesignal_app_id               : "---",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        maven {
            url 'http://dl.bintray.com/amulyakhare/maven'
            maven { url 'https://dl.bintray.com/alexeydanilov/maven' }
        }
        maven {
            url 'https://raw.githubusercontent.com/felixb/mvn-repo/master/'
        }
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        mavenCentral()
    }

}

dependencies {
    compile "com.splitwise:tokenautocomplete:2.0.8@aar"
    compile 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
    compile 'com.viewpagerindicator:viewpagerindicator:2.4.3'
    compile 'com.anjlab.android.iab.v3:library:1.0.44'
    compile 'com.onesignal:OneSignal:[3.9.1, 3.99.99)'
    compile 'com.google.firebase:firebase-auth:15.0.0'
    compile 'com.google.android.gms:play-services-safetynet:15.0.0'
    compile 'com.android.support:design:27.1.1'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.github.amlcurran.showcaseview:library:5.4.3'
    compile 'com.android.support:multidex:1.0.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
apply plugin: 'com.google.gms.google-services'
user934820
  • 1,162
  • 3
  • 17
  • 48
  • Possible duplicate of [Google sign in not working after publishing in play store](https://stackoverflow.com/questions/39318370/google-sign-in-not-working-after-publishing-in-play-store) – Sheikh Hasib Jun 03 '18 at 08:47
  • I have already checked the answer there and explained in my question that why I am re-posting the similar issue – user934820 Jun 03 '18 at 08:48
  • could you please add grandle files too? – Paraskevas Ntsounos Jun 04 '18 at 08:42
  • This has happened to me. What I did is I took `release SHA-1 fingerprint` keys of my project and created new `OAuth in google developer console for my already existing project with this new fingerprint and package name`. Once you finish, this will update `google-services.json` file in `Firebase`. You just need to `download that updated json file from firebase project settings` and add that file to your android project and create release build. – Mohammed Farhan Jun 04 '18 at 09:08
  • I have verified that both debug and release oauth_client ids are added automatically by google in google-services.json. In OAuth 2.0 section of console both clients are also automatically created by google. – user934820 Jun 04 '18 at 10:54
  • try not to sign apk in google play console. If you do, then SHA-1 for release may change. Just skip app signing in console. – Mohammed Farhan Jun 04 '18 at 11:12

2 Answers2

4

We faced this issue for our App very recently, which was integrated with Firebase authentication.

The APK was working fine and the OTP for the phone numbers were coming properly. But the same APK, when downloaded from Google Play, was not working because, the OTP for phone numbers were not coming.

As mentioned above, the reason for this issue was : We had signed our App with Google Play, which had signed it with a new SHA-1 fingerprint.

Now instead of rebuilding the APK with this new SHA-1 generated by Google Play, you can add this SHA-1 to your Firebase Project Overview > Add Fingerprint. This made our App from Google Play to start working.

DK Pati
  • 51
  • 4
  • Correct answer Pati but I feel it would be better if you demonstrated how to navigate to the SHA1. Also possible duplicate for https://stackoverflow.com/questions/39318370/google-sign-in-not-working-after-publishing-in-play-store – Brian Aug 10 '20 at 14:49
-1

If you already add sha 1 and all then please check Android device api is active or not and plz do active it https://console.cloud.google.com/apis/library/androidcheck.googleapis.com

  • Please read [https://meta.stackexchange.com/questions/7656/how-do-i-write-a-good-answer-to-a-question](https://meta.stackexchange.com/questions/7656/how-do-i-write-a-good-answer-to-a-question) – Sfili_81 Mar 16 '21 at 12:50