Facebook SDK and Audience Network SDK Android conflict

Hi guys, I am using the Facebook SDK in my project and I want also to integrate Facebook’s Audience Network SDK. The problem at first that both SDKs come with Android Support libraries, so when I try to build the project the process breaks when converting from java to dex:

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:/Program Files/Java/jdk1.8.0_92\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Android/sdk	ools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
....]

I try to fix this by removing this library from one of the two SDKs, but in both cases I get another error:

Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:/Program Files/Java/jdk1.8.0_92\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Android/sdk	ools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

stderr[

trouble writing output: Too many method references: 65909; max is 65536.
You may try using --multi-dex option.
References by package:
     6 android.accessibilityservice
     5 android.accounts
     12 android.animation
...... (It keeps going with a long list)

I just have no idea on what is causing this second error. Curiously though, if I remove the library from both SDKs, the project will build, but I guess the SDKs won’t work properly.

Any clues?

Thanks!

Regarding your first issue - it appears that you have 2 copies of the same Android (java) library in your project (Android support library). You should only ever include 1 copy of any library, as this will cause conflicts (as I explained in this answer: http://answers.unity3d.com/answers/767102/view.html

Then, you said you removed the library from one of the SDKs, and received another error. You can further read about this particular error here: Enable multidex for apps with over 64K methods  |  Android Studio  |  Android Developers

This is a limitation on Android (you cannot have more than 64k methods).

Is there any particular reason your (native) Android code has so many methods? are you using many plugins in your game? You should remove some plugins, and if this is not possible, resort to other measures such as stripping unused methods (not very convenient, i don’t think Unity supports that so well).