title: Google Firebase Authentication Android Studio
body: <p>Im attempting to configure the new google firebase authentication in my app.</p>
  
  <p>I am receiving <code>cannot resolve 'addOnCOmpleteListener'</code> when running the following within the <code>OnClickListener</code> for the button.</p>
  
  <p>If i move the <em>firebase</em> call out of the buttons <code>onClickListener</code> then the error goes,</p>
  
  <p>I cant quite understand why the method is not accessible from within the button call</p>
  
  <p>Any Help would be appreciated</p>
  
  <pre><code>package com.example.alex.test;
  
  import android.app.Activity;
  import android.app.Application;
  import android.content.Context;
  import android.net.Uri;
  import android.support.annotation.NonNull;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import com.google.android.gms.tasks.OnCompleteListener;
  import com.google.android.gms.tasks.Task;
  import com.google.firebase.auth.AuthResult;
  import com.google.firebase.auth.FirebaseAuth;
  import com.google.firebase.auth.FirebaseUser;
  
  
  public class LoginActivity extends AppCompatActivity {
      private FirebaseAuth mAuth;
  
      private FirebaseAuth.AuthStateListener mAuthListener;
  
      Button buttonLogin;
      EditText textEmail;
      EditText textPassword;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
  
          mAuth = FirebaseAuth.getInstance();
  
          buttonLogin = (Button) findViewById(R.id.buttonLogin);
          textEmail = (EditText) findViewById(R.id.editEmail);
          textPassword = (EditText) findViewById(R.id.editPassword);
  
          mAuthListener = new FirebaseAuth.AuthStateListener() {
              @Override
              public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                  FirebaseUser user = firebaseAuth.getCurrentUser();
                  if (user != null) {
                      // User is signed in
                      Log.d("LOG_Login", "onAuthStateChanged:signed_in:" + user.getUid());
                  } else {
                      // User is signed out
                      Log.d("LOG_Login", "onAuthStateChanged:signed_out");
                  }
                  // ...
              }
          };
  
  
  
  
          buttonLogin.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  // Perform action on clic
  
                  mAuth.signInWithEmailAndPassword(textEmail.getText().toString(),textPassword.getText().toString())
                          .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                              @Override
                              public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                                  Log.d("LOG_Login", "signInWithEmail:onComplete:" + task.isSuccessful());
  
                                  // If sign in fails, display a message to the user. If sign in succeeds
                                  // the auth state listener will be notified and logic to handle the
                                  // signed in user can be handled in the listener.
                                  if (!task.isSuccessful()) {
                                      Log.w("LOG_Login", "signInWithEmail", task.getException());
                                      Toast.makeText(getApplicationContext(), "Authentication failed.", Toast.LENGTH_SHORT).show();
                                  }
  
                                  // ...
                              }
                          });
              }
          });
  
      }
  }
  </code></pre>
  
  <p>i am using Android Studio 2.2</p>
  
  <p>I have created a project within Firebase</p>
  
  <p>I have connected my app to this within the GUI</p>