title: Why android Facebook integration crash?
body: <p>I am trying to integrate Android application with facebook. I am following these tutorials:
  <a href="https://developers.facebook.com/docs/android/getting-started" rel="nofollow">https://developers.facebook.com/docs/android/getting-started</a></p>
  
  <p><a href="http://code.tutsplus.com/tutorials/quick-tip-add-facebook-login-to-your-android-app--cms-23837" rel="nofollow">http://code.tutsplus.com/tutorials/quick-tip-add-facebook-login-to-your-android-app--cms-23837</a>   </p>
  
  <p>But I am facing the following problems :</p>
  
  <pre><code>01-05 12:52:45.325 463-463/socialmediaintegration.arifhasnat.com.facebooklogin E/AndroidRuntime: FATAL EXCEPTION: main
  Process: socialmediaintegration.arifhasnat.com.facebooklogin, PID: 463
  java.lang.ExceptionInInitializerError
      at java.lang.reflect.Constructor.constructNative(Native Method)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at android.view.LayoutInflater.createView(LayoutInflater.java:594)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
      at socialmediaintegration.arifhasnat.com.facebooklogin.MainActivity.onCreate(MainActivity.java:24)
      at android.app.Activity.performCreate(Activity.java:5293)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
      at android.app.ActivityThread.access$800(ActivityThread.java:151)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
      at android.os.Handler.dispatchMessage(Handler.java:110)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:5299)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:830)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:646)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: null
      at com.facebook.internal.Validate.sdkInitialized(Validate.java:99)
      at com.facebook.FacebookSdk.getCallbackRequestCodeOffset(FacebookSdk.java:735)
      at com.facebook.internal.CallbackManagerImpl$RequestCodeOffset.toRequestCode(CallbackManagerImpl.java:109)
      at com.facebook.login.widget.LoginButton.&lt;clinit&gt;(LoginButton.java:58)
      at java.lang.reflect.Constructor.constructNative(Native Method) 
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
      at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
      at socialmediaintegration.arifhasnat.com.facebooklogin.MainActivity.onCreate(MainActivity.java:24) 
      at android.app.Activity.performCreate(Activity.java:5293) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
      at android.app.ActivityThread.access$800(ActivityThread.java:151) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
      at android.os.Handler.dispatchMessage(Handler.java:110) 
      at android.os.Looper.loop(Looper.java:193) 
      at android.app.ActivityThread.main(ActivityThread.java:5299) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:830) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:646) 
      at dalvik.system.NativeStart.main(Native Method) 
  </code></pre>
  
  <p>Here is my code:
  MainActivity.java</p>
  
  <pre><code>package socialmediaintegration.arifhasnat.com.facebooklogin;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.widget.TextView;
  
  import com.facebook.CallbackManager;
  import com.facebook.FacebookCallback;
  import com.facebook.FacebookException;
  import com.facebook.FacebookSdk;
  import com.facebook.login.LoginResult;
  import com.facebook.login.widget.LoginButton;
  
  public class MainActivity extends AppCompatActivity {
      private TextView info;
      private LoginButton loginButton;
      private CallbackManager callbackManager;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          FacebookSdk.sdkInitialize(getApplicationContext());
          callbackManager = CallbackManager.Factory.create();
  
          info = (TextView)findViewById(R.id.info);
          loginButton = (LoginButton)findViewById(R.id.login_button);
  
          loginButton.registerCallback(callbackManager, new FacebookCallback&lt;LoginResult&gt;() {
              @Override
              public void onSuccess(LoginResult loginResult) {
  
                  info.setText(
                          "User ID: "
                                  + loginResult.getAccessToken().getUserId()
                                  + "\n" +
                                  "Auth Token: "
                                  + loginResult.getAccessToken().getToken()
                  );
  
  
              }
  
              @Override
              public void onCancel() {
                  info.setText("Login attempt canceled.");
  
              }
  
              @Override
              public void onError(FacebookException e) {
                  info.setText("Login attempt failed.");
  
              }
          });
  
  
  
  
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          callbackManager.onActivityResult(requestCode, resultCode, data);
      }
  
  
  }
  </code></pre>
  
  <p>menifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="socialmediaintegration.arifhasnat.com.facebooklogin" &gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme" &gt;
          &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar" &gt;
              &lt;meta-data android:name="com.facebook.sdk.ApplicationId"
                  android:value="@string/facebook_app_id"/&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name="com.facebook.FacebookActivity"
              android:configChanges=
                  "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
              android:theme="@android:style/Theme.Translucent.NoTitleBar"
              android:label="@string/app_name" /&gt;
          &lt;provider android:authorities="com.facebook.app.FacebookContentProvider1234"
              android:name="com.facebook.FacebookContentProvider"
              android:exported="true" /&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent" android:layout_height="match_parent"
      android:padding="16dp"
      &gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/info"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:textSize="18sp"
          /&gt;
  
      &lt;com.facebook.login.widget.LoginButton
          android:id="@+id/login_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true"
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And gradle  dependencies :</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 23
      buildToolsVersion "23.0.2"
  
      defaultConfig {
          applicationId "socialmediaintegration.arifhasnat.com.facebooklogin"
          minSdkVersion 16
          targetSdkVersion 23
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.1.1'
      compile 'com.android.support:design:23.1.1'
      compile 'com.facebook.android:facebook-android-sdk:4.0.0'
  }
  </code></pre>