0
votes

I have made my application and published it to google play store. I used Firebase Phone Authentication for verification members, before I released it to the play store it worked fine, but when I downloaded it from google play it throws an error saying:
(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. [App validation faild])

I also added App Signing of SHA 1, SHA 256 and Upload SHA 1, SHA 256 of my application in google play console, but unfortunately, it doesn't work.

Screen Shot

3

3 Answers

0
votes

The problem is that you have added SHA1 & SHA256 for Debug and release that why it worked before uploading it to play store.

Solution

Contact the person who has Google play store account. GET SHA1 & SHA256 of play store from him and add to Firebase console.

Verify the following

1- Package name

2- Sha 1 & Sha 256

3- Add Safetynet code to your app

    fun request_safetynet(){
    SafetyNet.getClient(this)
        .enableVerifyApps()
        .addOnCompleteListener { task ->
            if (task.isSuccessful) {
                if (task.result.isVerifyAppsEnabled) {
                    Log.e("SAFETYNET", "The user gave consent to enable the Verify Apps feature.")
                   // Toast.makeText(this,"user gave consent",Toast.LENGTH_SHORT).show()
                } else {
                    Log.e(
                        "SAFETYNET",
                        "The user didn't give consent to enable the Verify Apps feature."

                    )
                  //  Toast.makeText(this,"user didn't give consent",Toast.LENGTH_SHORT).show()

                }
            } else {
                Log.e("SAFETYNET", "A general error occurred.")
               // Toast.makeText(this,"general error occurred",Toast.LENGTH_SHORT).show()

            }
        }



}

fun safetynet_Verify_enabled(){
    SafetyNet.getClient(this)
        .isVerifyAppsEnabled
        .addOnCompleteListener { task ->
            if (task.isSuccessful) {
                if (task.result.isVerifyAppsEnabled) {
                    Log.e("SAFETYNET", "The Verify Apps feature is enabled.")
                    //Toast.makeText(this,"Verify Apps feature is enabled.",Toast.LENGTH_SHORT).show()

                } else {
                    Log.e("SAFETYNET", "The Verify Apps feature is disabled.")
                   // Toast.makeText(this,"The Verify Apps feature is disabled.",Toast.LENGTH_SHORT).show()

                }
            } else {
                Log.e("SAFETYNET", "A general error occurred.")
                //Toast.makeText(this,"safetynet_Verify_enabled : general error occurred",Toast.LENGTH_SHORT).show()

            }
        }
}
0
votes

If Firebase Phone Authentication for debug apk is running successfully but not for release apk then there is issue in your keys .

Use this command to generate release keys: keytool -list -v -keystore "your jks file path " -alias "key name"

Add jks path and key name and run this command in android studio terminal.

OR

You can also get SHA1 and SHA- 256 from google play console . Go to Play store Console > Your project > Release > Setup > App signing .

  1. Copy SHA1 and SHA- 256 keys and paste in firebase console .
  2. If your firebase-auth version is above than 20.0.0 then you also need to configure safetynet in your project. For more info check this
  3. Make sure PHONE AUTHENTICATION is enabled . Go to Firebase console -> Authentication -> Sign-in Methods.
  4. After adding keys , download updated google-services.json and add in your project.
  5. Clean project and then rebuild project.
  6. Test your app again (In order to prevent abuse the firebase phone authentication wont work in emulator so test on real device)

android studio terminal goole console app signing key

0
votes

I have did these steps, then its worked after downloading from play store:

In firebase console i have created a new project by its default name Google Play Console Developer ... and added sha1 and sha256 from application and copied google.json file to application, then: Play Console -> Settings -> Developer account -> API access: Then i have linked the created firebase project Google Play Console Developer... with google, after that on opened paged i have added Credentials. After that everythings work fine.