title: android.view.InflateException: Error inflating class com.facebook.login.widget.LoginButton
body: <p>I am integrating facebook login in an android app with firebase.
  The app crash when the login activity starts and shows the following error</p>
  
  <blockquote>
    <p>Unable to start activity ComponentInfo{com.environer.behappy/com.environer.behappy.LoginActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.facebook.login.widget.LoginButton</p>
  </blockquote>
  
  <p><strong>In new facebook SDK there is no need to initialize the sdk by calling FacebookSdk.initializeSdk() since it will be auto initialized</strong></p>
  
  <p><strong>I have imported the login button using com.facebook.login.widget.LoginButton</strong></p>
  
  <p><strong>I also have called onActivityResult on CallBackManager</strong></p>
  
  <p>My Code is below</p>
  
  <pre><code> @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_login);
      mCallBackManager = CallbackManager.Factory.create();
      ButterKnife.bind(this);
      mAuth = FirebaseAuth.getInstance();
      configureGoogleSignIn();
  }
  @OnClick(R.id.button_facebook)void facebookSignIn(){
  
      LoginButton loginButton = (LoginButton) findViewById(R.id.button_facebook);
      loginButton.setReadPermissions("email","public_profile");
      loginButton.registerCallback(mCallBackManager, new FacebookCallback&lt;LoginResult&gt;() {
          @Override
          public void onSuccess(LoginResult loginResult) {
              handleFacebookAccessToken(loginResult.getAccessToken());
          }
  
          @Override
          public void onCancel() {
              Toast.makeText(LoginActivity.this, getString(R.string.loginCancel), Toast.LENGTH_SHORT).show();
          }
  
          @Override
          public void onError(FacebookException error) {
              Toast.makeText(LoginActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
          }
      });
  
  }
  
  private void handleFacebookAccessToken(AccessToken accessToken) {
      AuthCredential credential = FacebookAuthProvider.getCredential(accessToken.getToken());
      mAuth.signInWithCredential(credential)
              .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                      if(task.isSuccessful()){
                          FirebaseUser user = mAuth.getCurrentUser();
                          Toast.makeText(LoginActivity.this, getString(R.string.welcomeText) + user.getDisplayName(), Toast.LENGTH_SHORT).show();
                      }
                      else{
                          Toast.makeText(LoginActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
                      }
                  }
              });
  }
   @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if(requestCode == SIGNIN_CODE){
          GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
          if(result.isSuccess()){
              GoogleSignInAccount account = result.getSignInAccount();
              firebaseAuthWithGoogle(account);
          }
          else{
              //Google signin Failed
              Toast.makeText(this, result.getStatus().toString(), Toast.LENGTH_SHORT).show();
          }
      }else{
          super.onActivityResult(requestCode,resultCode,data);
          mCallBackManager.onActivityResult(requestCode,resultCode,data);
      }
  
  }
  </code></pre>
  
  <p>My XML Code</p>
  
  <pre><code>&lt;com.facebook.login.widget.LoginButton
      android:background="@color/colorPrimary"
      android:id="@+id/button_facebook"
      android:layout_width="300dp"
      android:layout_height="60dp"
      android:textSize="20sp"
      android:paddingTop="10dp"
      android:paddingBottom="10dp"
      android:layout_below="@+id/imageViewGmail"
      android:layout_alignLeft="@+id/imageViewGmail"
      android:layout_alignStart="@+id/imageViewGmail"
      android:layout_marginTop="12dp" /&gt;
  </code></pre>