While building my Android game using Unity3D, I ran into a frustrating error that brought development to a halt. I was integrating the Facebook SDK and PlayFab SDK, and everything seemed fine until I tried to build for Android. Suddenly, Unity threw an error about plugins “colliding with each other.” If you’re working with third-party SDKs, chances are you’ll face something similar. Here’s how I tackled it, what I learned, and how you can avoid it.
Initial Setup
In my case, the project setup was fairly standard:
- Unity3D project targeting Android
- Minimum SDK version: 19 (recommended for modern support)
- Integrated:
- Facebook SDK for Unity
- PlayFab SDK
Everything was working great in the editor. But when I hit Build, Unity gave me this error:
Error Detail
Found plugins with same names and architectures,
Assets/Plugins/Android/libs/android-support-v4.jar (ARMv7)
and Assets/Plugins/Android/android-support-v4.jar (ARMv7).
Assign different architectures or delete the duplicate.
What does that mean?
Basically, Unity found two versions of the same file (android-support-v4.jar
) in different folders. One was in:
Assets/Plugins/Android/libs/
- The other in
Assets/Plugins/Android/
Because both are targeting the same architecture (ARMv7), Unity doesn’t know which one to use. This results in a build failure.
Initial Code Facebook + PlayFab Integration
Here’s a simplified version of my GameManager.cs
script:
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;
using Facebook.Unity;
public class GameManager : MonoBehaviour
{
void Start()
{
if (!FB.IsInitialized)
{
FB.Init(OnFBInitComplete, OnHideUnity);
}
else
{
FB.ActivateApp();
}
PlayFabLogin();
}
void OnFBInitComplete()
{
if (FB.IsInitialized)
{
FB.ActivateApp();
}
else
{
Debug.LogError("Failed to initialize Facebook SDK");
}
}
void OnHideUnity(bool isGameShown)
{
Time.timeScale = isGameShown ? 1 : 0;
}
void PlayFabLogin()
{
var request = new LoginWithCustomIDRequest { CustomId = "UnityPlayer", CreateAccount = true };
PlayFabClientAPI.LoginWithCustomID(request,
result => Debug.Log("PlayFab Login Success!"),
error => Debug.LogError("PlayFab Login Error: " + error.GenerateErrorReport())
);
}
}
Attempt Fix & A New Problem
Thinking I’d solved the issue, I deleted the file from libs/
. But then, Unity gave me a new error:
Main manifest has <uses-sdk /> but library uses minSdkVersion='15'
This happened because the Facebook SDK expects a minimum SDK version of 15, but my Unity project didn’t specify it properly. When Unity merges all the manifest files (which it does automatically), it found a mismatch.
The Fix
Resolve the Plugin Collision
- Keep one copy of
android-support-v4.jar
. - I kept the one in:
Assets/Plugins/Android/android-support-v4.jar
- Then deleted:
Assets/Plugins/Android/libs/android-support-v4.jar
Match the SDK Versions
- Go to
Edit > Project Settings > Player > Android
. - Under Other Settings, set:
- Minimum API Level to API 15 or higher.
- I recommend API 19 or even API 21 for better device coverage.
Verify AndroidManifest.xml
Ensure your main AndroidManifest.xml
looks like this:
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="30" />
And make sure no library manifest files are overriding this.
Plugin Checker Script
To avoid these problems in the future, I created a Unity Editor tool that checks for duplicate .jar
files. Here’s the code:
// Editor/PluginChecker.cs
using UnityEditor;
using UnityEngine;
using System.IO;
public class PluginChecker : EditorWindow
{
[MenuItem("Tools/Check Android Plugin Duplicates")]
static void CheckForDuplicates()
{
string[] jars = Directory.GetFiles("Assets/Plugins/Android", "*.jar", SearchOption.AllDirectories);
var duplicates = new System.Collections.Generic.Dictionary<string, string>();
foreach (string path in jars)
{
string fileName = Path.GetFileName(path);
if (duplicates.ContainsKey(fileName))
Debug.LogWarning($"Duplicate plugin found: {fileName}\n- {duplicates[fileName]}\n- {path}");
else
duplicates[fileName] = path;
}
}
}
Just run it from Unity’s top menu under:
🛠Tools > Check Android Plugin Duplicates
Final Thought
Plugin conflicts in Unity especially when working with Android SDKs are more common than I expected. But the fix usually comes down to clearing out duplicates, setting the correct SDK version, and making sure your manifest files play nicely together. If you’re working with multiple SDKs like Facebook and PlayFab, take the time to manage your Android plugins cleanly. And always double-check your build settings before going live.