- Home /
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\tools" -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\tools" -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!
I am also facing the same problem. There seems to be some problem with the Facebook Ads plugin.
Are you able to export the project to android studio ?
No, I have never done that. I have no experience with Android Studio
Answer by liortal · Jul 16, 2016 at 11:17 AM
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: https://developer.android.com/studio/build/multidex.html
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).
Thanks for the hint! If I find a definitive solution I will post it here
Your answer
Follow this Question
Related Questions
Not pushing content to device 0 Answers
Android - Building Beta Problems. 0 Answers
Android - Failed to repackage resources error after installing facebook plugin 2 Answers
I have a problem with my sdk version. Please help me 0 Answers
Can't build for Android 0 Answers