Android AddThis sdk + Facebook sdk won't build in Android Studio
Asked Answered
C

1

3

I have a project I'm working on in Android Studio that currently uses the Facebook SDK for retrieving some information about a Facebook user. It works pretty well.

I also need to implement AddThis, however when I try to compile this project with both SDKs referenced, I get the error:

Android Dex: [<removed>] com.android.dx.util.DexException: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;

Inside the AddThis .jar, as expected, com.facebook.android.AsyncFacebookRunner exists. Obviously it also exists in the Facebook SDK module. There is functionality that I need in AddThis that doesn't exist in Facebook, and vice versa.

Does anyone know a way to handle this type of situation?

Chrischrism answered 15/8, 2013 at 22:2 Comment(1)
This is using Facebook SDK version 3.0, and AddThis SDK version 0.0.8Chrischrism
C
3

I was able to resolve this issue:

Since the Facebook SDK is a module and not a jar, I referenced AddThis0.8.8.jar from the Facebook SDK module, and removed the reference to it from my project directly.

After doing so, there was still a conflict between com.facebook.android.* in the Facebook SDK and the duplicate ( com.facebook.android.* ) in the AddThis jar. So, I deleted the com.facebook.android package along with it's contents - from the Facebook SDK - then included com.addthis in ( class path, I think? Android Studio suggested to include it when I typed "ATButton" in code. I said "Heck yea, thanks JetBrains!" ).

I am now able to use AddThis as well as the Facebook SDK without any conflicts.

I hope this process can help someone out there in some way.

[Edit]

There were still problems with this. I reverted the Facebook SDK, and removed the Facebook stuff from the AddThis jar. Not 100% working still, but probably a better idea to keep all Facebook stuff in the Facebook module. Please do post an answer if you have a better solution.

Chrischrism answered 15/8, 2013 at 23:3 Comment(4)
This is very hacky and resulted in some issues, including com.addthis.* activities defined in the project's AndroidManifest.xml not being strongly typed. I strongly encourage anyone w/ a better solution to share it as an answer.Chrischrism
+1 You are brilliant ! Thanks so much I spent like a day solving this issue, It's actually kind of stupid thing that AddThis includes a part of FacebookSDK , Putting you the poor developer between accept only the library or the FacebookSDK but thanks for your solution Problem is Solved :)Greenlee
Do you know how you removed the Facebook directory from addthis0.0.8.jar ? I decompressed it, deleted the directory, then used jar cf addthis0.0.8.jar addthis0.0.8 but now Android Studio says it can't find com.addthis.core, etc.Alishiaalisia
You can see my comments on how I got this working #25964723Alishiaalisia

© 2022 - 2024 — McMap. All rights reserved.