Troubles getting Facebook SDK working.

Okay, so I have this bug - and I need a fresh pair of eyes… It’s honestly draining my will to live and it’s big enough that I am considering domesticating him. I’ll name him Kevin or something.

Long story short, working on a game, have GPGS integrated but dormant and I’ve now taken up the task of adding the Facebook SDK to sort out Facebook Logins.

I cannot for the life of me get this to compile - I’ve spent a solid 12 hours on this and I am at breaking point. The problem would appear to be with my android manifest files.

Merge Error 1

Merge Error 2

Merge Error 3

Android Manifest Merge Issue

My current google android-manifest.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<!-- This file was automatically generated by the Google Play Games plugin for Unity
     Do not edit. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.example.games.mainlibproj"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" />

    <application>

     <!-- Required for Nearby Connections API -->
        <meta-data android:name="com.google.android.gms.nearby.connection.SERVICE_ID"
            android:value="" />

        <!-- the space in these forces it to be interpreted as a string vs. int -->
        <meta-data android:name="com.google.android.gms.games.APP_ID"
            android:value="\ CENSOREDNUMBERS" />
        <meta-data android:name="com.google.android.gms.games.unityVersion"
            android:value="\ 0.9.34" />
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity android:name="com.google.games.bridge.NativeBridgeActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    </application>
</manifest>

Aaaand the Facebook one looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
    <activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
    <activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
    <activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
    <activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
    <activity android:name="com.facebook.unity.AppInviteDialogActivity" />
    <provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProviderCENSOREDNUMBERS" android:exported="true" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />

    <activity android:name="com.facebook.CustomTabActivity" android:exported="true">

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="@string/fb_login_protocol_scheme" />
    </intent-filter>

	</activity>
	<activity android:name="com.facebook.CustomTabMainActivity" android:exported="true">
    </activity>

  </application>
  <uses-permission android:name="android.permission.INTERNET"/>

</manifest>

Minimum API is set to level 16 under player settings. I also have the build tools from API level 16 to 25.

My strings.xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<string name="facebook_app_id">CENSOREDNUMBERS</string>
<string name="fb_login_protocol_scheme">fbCENSOREDNUMBERS</string>

And my layout.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
	xmlns:android="com.facebook.login.widget.LoginButton"
    android:id="@+id/login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="30dp"
    android:layout_marginBottom="30dp" > 
</LinearLayout>

Please, ANY help would be much appreciated, I just honestly don’t know what’s wrong.

Current Unity Version 5.4.1f1

Over 16 hours of struggling and I finally came right.

Turns out I was over complicating it. Forget adding anything to your android manifests. Simply fill out your app info in the Facebook window of unity. Then follow:

  • Delete or make a backup of your two existing android-manifest.xml files.
  • Run a clean compile, it will throw out an error as well as the Google play android-manifest.xml.
  • Restart Unity to unload any plugins.
  • Go to the Facebook settings in unity and regenerate your android manifest.
  • Open the google android-manifest.xml and set the min sdk to 16 and the target to 24.
  • Set minimum to 16 in your player settings.
  • Search for services(something).aar, and make sure there is only one, delete the outdated plugin.
  • Build and run.