title: Xamarin Android App not able to initialize the Facebook SDK
body: <p>Note: There are a lot of similar questions but non of them helped me, so I desiced to ask again for my case :)</p>
  
  <p>I'm trying to use the Facebook Button to Login in my Xamarin Android App.
  My Login.axml looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:minWidth="25px"
  android:minHeight="25px"&gt;
  
  &lt;com.facebook.login.widget.LoginButton
      android:id="@+id/facebookLoginButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal"
      android:layout_marginTop="30dp"
      android:layout_marginBottom="30dp" /&gt;
  &lt;/LinearLayout&gt;
  ...
  </code></pre>
  
  <p>And my Class I'm using the button at looks like this:</p>
  
  <pre><code>class FacebookLogin : Activity
  {
  
      LoginButton BtnFbLogin;
  
      protected override void OnCreate(Bundle savedInstanceState)
      {
          base.OnCreate(savedInstanceState);
          SetContentView(Resource.Layout.Login);
          BtnFbLogin = FindViewById&lt;LoginButton&gt;(Resource.Id.facebookLoginButton);
          BtnFbLogin.Click += delegate { LoginToFacebook(); };
      }
  ...
  </code></pre>
  
  <p>Every time, when I try to start the app I'm getting the following exception:</p>
  
  <pre><code>I/FacebookInitProvider( 4420): Failed to auto initialize the Facebook SDK
  I/FacebookInitProvider( 4420): A valid Facebook app id must be set in the 
  AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
  I/FacebookInitProvider( 4420):  at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:275)
  I/FacebookInitProvider( 4420):  at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:231)
  I/FacebookInitProvider( 4420):  at com.facebook.internal.FacebookInitProvider.onCreate(FacebookInitProvider.java:20)
  I/FacebookInitProvider( 4420):  at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
  I/FacebookInitProvider( 4420):  at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
  I/FacebookInitProvider( 4420):  at android.app.ActivityThread.installProvider(ActivityThread.java:5853)
  I/FacebookInitProvider( 4420):  at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)
  I/FacebookInitProvider( 4420):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)
  I/FacebookInitProvider( 4420):  at android.app.ActivityThread.-wrap2(ActivityThread.java)
  I/FacebookInitProvider( 4420):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
  I/FacebookInitProvider( 4420):  at android.os.Handler.dispatchMessage(Handler.java:102)
  I/FacebookInitProvider( 4420):  at android.os.Looper.loop(Looper.java:154)
  I/FacebookInitProvider( 4420):  at android.app.ActivityThread.main(ActivityThread.java:6119)
  I/FacebookInitProvider( 4420):  at java.lang.reflect.Method.invoke(Native Method)
  I/FacebookInitProvider( 4420):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
  I/FacebookInitProvider( 4420):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  D/Mono    ( 4420): Assembly Ref addref projectname[0x770ab9895a80] -&gt; Mono.Android[0x770aa4e70980]: 19
  D/Mono    ( 4420): DllImport searching in: '__Internal' ('(null)').
  D/Mono    ( 4420): Searching for 'java_interop_jnienv_get_array_length'.
  D/Mono    ( 4420): Probing 'java_interop_jnienv_get_array_length'.
  D/Mono    ( 4420): Found as 'java_interop_jnienv_get_array_length'.
  Loaded assembly: MonoDroidConstructors [External]
  D/Mono    ( 4420): Assembly Ref addref projectname[0x770ab9895a80] -&gt; mscorlib[0x770ab9895700]: 29
  D/Mono    ( 4420): Assembly Ref addref projectname[0x770ab9895a80] -&gt; Xamarin.Facebook[0x770aa4e70880]: 2
  D/        ( 4420): HostConnection::get() New Host Connection established 0x770aa3d96560, tid 4420
  W/        ( 4420): Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 
  W/        ( 4420): Process pipe failed
  D/Mono    ( 4420): DllImport searching in: '__Internal' ('(null)').
  D/Mono    ( 4420): Searching for 'java_interop_jnienv_call_void_method_a'.
  D/Mono    ( 4420): Probing 'java_interop_jnienv_call_void_method_a'.
  D/Mono    ( 4420): Found as 'java_interop_jnienv_call_void_method_a'.
  Unhandled Exception:
  
  Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class com.facebook.login.widget.LoginButton
  </code></pre>
  
  <p>Basically it says, that a valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk. The method for setting the ApplicationId manually is depricated since Xamarin auto-initializes the Facebook SDK. So I've set the ApplicationId in the Manifest file, which now looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="projectname.projectpackage" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"&gt;
      &lt;uses-sdk android:minSdkVersion="21" android:targetSdkVersion="23" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;application android:allowBackup="true" android:label="@string/app_name" android:theme="@android:style/Theme.Material.Light"&gt;&lt;/application&gt;
  
    &lt;meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/&gt; &lt;!--is defined in Strings.xml --&gt;
  
    &lt;activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
                  "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" /&gt;
    &lt;activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true"&gt;
      &lt;intent-filter&gt;
        &lt;action android:name="android.intent.action.VIEW" /&gt;
        &lt;category android:name="android.intent.category.DEFAULT" /&gt;
        &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
        &lt;data android:scheme="@string/fb_login_protocol_scheme" /&gt;
      &lt;/intent-filter&gt;
    &lt;/activity&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>What am I doing wrong? Why Am I getting this exception?</p>