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?

Shaggy
  • 163
  • 2
  • 10

1 Answers1

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.

Shaggy
  • 163
  • 2
  • 10
  • 1
    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. – Shaggy Aug 15 '13 at 23:38
  • +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 :) – Youans Oct 01 '13 at 19:33
  • 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. – Chris Sep 22 '14 at 15:09
  • You can see my comments on how I got this working http://stackoverflow.com/questions/25964223/android-studio-app-crashing-on-addthis-jar-sources-not-found-message/25979176#25979176 – Chris Sep 22 '14 at 16:51