问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/18262647/android-addthis-sdk-facebook-sdk-wont-build-in-android-studio