0

My app has been publish for a while and Google Sign in was working fine untill now. It just suddenly stopped working. I've checked everything includeing SHA-1 fingerprint, client_id etc.

Upon testing i've found out that the result activity doens't return RESULT_OK.

private lateinit var googleSignInClient: GoogleSignInClient

private var googleSigninLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){

    if(it.resultCode == RESULT_OK){
        val task = GoogleSignIn.getSignedInAccountFromIntent(it.data)
        try {
            val account = task.getResult(ApiException::class.java)
            account.idToken?.let {token->
                firebaseAuthWithGoogle(token)
            }

        } catch (e: ApiException) {
            Log.d("LOGIN_DEBUG", e.message.toString())
        }
    }else{
        //This is where the code reaches and I am getting RESULT_CODE 0 in the logs
        toast(this@MainActivity, getString(R.string.there_was_an_error))
        Log.d("LOGIN_DEBUG", it.resultCode.toString())
    }
}


val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build()

    googleSignInClient = GoogleSignIn.getClient(this, gso)


google_signin.setOnClickListener {
        val signInIntent = googleSignInClient.signInIntent

        googleSigninLauncher.launch(signInIntent)
        toast(this@MainActivity, resources.getString(R.string.please_wait))
    }

I've looked at a lot of questions but none of the solutions are working for me. Any help is greatly appreciated.

Danish Ajaib
  • 83
  • 1
  • 3
  • 14
  • "It just suddenly stopped working" doesn't provide enough information so we can help. Does your app crash? If the app crashes, there is a stack trace. Please look that up on logcat, and add it to your question. – Alex Mamo Dec 30 '21 at 11:02
  • @AlexMamo ..its doesn't crash.. nothing happens. when I tap on sign in..I get the account selector, after selecting the account nothing happens. I do not get any errors in the log. Also, if you check above, I mentioned what's happening. the onResult RESULT_CODE doesn not return OK. it turns a RESULT_CODE of 0. – Danish Ajaib Dec 30 '21 at 13:08
  • [Here](https://medium.com/firebase-tips-tricks/how-to-create-an-android-app-using-multiple-firebase-products-in-kotlin-16aade81ffec) you can find a working solution. – Alex Mamo Dec 30 '21 at 13:47
  • thanks @AlexMamo , unfortunately that doesn't resolve my problem. – Danish Ajaib Dec 30 '21 at 14:21

2 Answers2

1

Could you please check your google-services.json file ?

check if your publishing SHA-1 is existed.

If play console generates the signing key so the SHA-1 of this key have to be added in firebase then download google service file again

you can find it in you app page in play console (Release -> Setup -> App Integrity)

And if you publishing with your signing key generate the signing report from android studio (also you can find the SHA-1 in play console) and make sure this SHA-1 added to firestore then download the file again

Hussien Fahmy
  • 1,119
  • 6
  • 24
0

As Mentioned in this Answer.

Try checking if you have the correct OAuth key properly configured for your app. According to this related SO post, the OP noticed that the Auth key is also associated with other project that create the issue.

Additionally, make sure you have signed the APK while you're testing. Read the documentation for signing your app.

Pierre Janineh
  • 394
  • 2
  • 13