title: How to implement google sign in
body: <p>I implemented the google sign in api in my android app. Everything was fine until recently. One of the challenges I had was with client_id which regenerated. The most recent that has opened more errors is that the google sign in wont work in the release.apk that built.</p>
  <p>After two days of debugging I decided to create a new demo project to start the process afresh. It won't work as the task return <code>false</code> for <code>task.isSuccessful</code>.</p>
  <p>Perhaps there is something I am missing.</p>
  <pre><code>const val RC_SIGN_IN = 0
  class MainActivity : AppCompatActivity() {
      lateinit var observer:StartActivityForResults
      private lateinit var mGoogleSignInClient:GoogleSignInClient
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          observer = StartActivityForResults(activityResultRegistry)
          lifecycle.addObserver(observer)
  
          val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                  .requestEmail()
                  .build()
  
          mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
  
          sign_in_button.setOnClickListener{
              signIn()
          }
      }
  
      private fun signIn() {
  
  
          val signInIntent = mGoogleSignInClient.signInIntent
  
          startActivityForResult(signInIntent, RC_SIGN_IN)
      }
  
      override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
          super.onActivityResult(requestCode, resultCode, data)
  
          // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
          if (requestCode == RC_SIGN_IN) {
              // The Task returned from this call is always completed, no need to attach
              // a listener.
              val task = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
  
              task?.isSuccess
  
              Toast.makeText(this, &quot;Success&quot;, Toast.LENGTH_LONG).show()
          }
          else{
              Log.i(&quot;title&quot;, &quot;OKCODE ${Activity.RESULT_OK} RESULTCODE ${resultCode}&quot;)
          }
      }
  }
  </code></pre>