Android AddThis sdk + Facebook sdk won't build in Android Studio - android

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?

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.

Related

Why does the Facebook Android SDK downloaded and included via jar show up as an unresolved reference in Android Studio

I was unable to include the Facebook Android SDK in the normal way so I downloaded a jar and added it to Android Studio. For some strange reason I get an error Unresolved reference: FacebookSdk even though I can see the class in the Project view:
If I am doing the wrong thing can somebody please give a lucid explanation of how to download and use the Facebook SDK in Android Studio 3.
Edit
I need to use the Facebook SDK in my app and I need to download it and add it 'offline'.
this is the sources package (as it's filename may hint for), which is for reference only. you should possibly add a dependency to the build.gradle instead; it's from the mavenCentral() repository, you can also find the artifacts here ...and a whole lot of other Facebook SDKs here.
dependencies {
implementation "com.facebook.android:facebook-android-sdk:4.36.0"
}
and also move those sources outside of the libs directory
(they still can be linked together with the fetched library).

Is Android Support Reposity includeable in Eclipse Neon?

for certain compatibility reasons, I have to use Eclipse Neon for Android Development to develop an android app. Therefore I also have to use the newest Android SDK so I can implement some newest features.
Now, I am facing the problem that I cannot compile any Android app with Eclipse, because I get errors like
The import android.support cannot be resolved
ActionBarActivity cannot be resolved to a type
Error retrieving parent for item: No resource found that matches the given name "ThemeAppCompat. …"
upon building. As I found out, this is because Eclipse is missing the "Android support library" (android support library.jar ?) in the sdk folder. The reason for this is, as I found out, that this library is obsolete and has been replaced by the "Android support repository". It has not been installed by the Android SDK manager and cannot be installed anymore, but Eclipse still needs it apparently.
I searched a lot for a solution for this but all answers I could find was "Swtich to Android Studio"… Unfortunately, there is no way around using Eclipse for me. Is there any known way to include the support repository and make eclipse use it? I found this site
https://developer.android.com/topic/libraries/support-library/setup.html
and thought, maybe I can follow these steps to make my app to a gradle.build and then include the stuff from the repository and get my stuff to work, but unfortunately I could not find a way to realize this.
I changed the related section in the gradle.build file to this:
…
dependencies {
…
compile 'com.android.support:appcompat-v7:24.0.0'
}
…
but could not get the app being built.
Is there any known solution for this? I actually cannot imagine that I am the only one trying to develop an Android App with the new support repository file these days. Should I maybe manually insert the obsolete (but newest) android support library.jar file from an older IDE? Could this work?
Thank you many times for your help.

NoClassDefFoundError in facebook integeration

I am using facebook integration API in my code. I have created sha1 key for Facebook,I got my APIID ,but the problem is that when I am trying to add facebook library in my project it's adding fine ,but when I am running it, its giving me NoClassDefFoundError error and library is not adding properly, where am I doing wrong?
Here is the image:
Here my facebook library is not adding properly, What should I do ?
Your facebook SDK library project and your Current Android project both should be in same directory. Try moving your facebook sdk library to your project's folder then it will 100% work properly.
For future reference always remember that your library project must me in same folder where your appliction is.
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.
Hope this helps.
Move your Facebook SDK library to your project's work space then it will 100% work properly.I think they both are not in the same directory , and you are suggested to check the other imports of any other project of your work space and put the Facebook SDK same as the others.

Problems converting to library project including Facebook SDK

I have a working app that I've now converted to being a library project in Eclipse. When I attempt to include the library as a "Project Reference" in an empty app (no other functionality other than what it inherits from the library) it fails to build. I get the message Unable to execute dex: Multiple dex files define Lcom/facebook/android/R$attr;.
To try to work around this I tried to delete the Android Dependencies completely. But then I get a "Class not found exception" for classes in the library.
Is it possible to remove the Facebook dependency without also removing the app library dependency? I tried to delete the facebooksdk.jar file but was unable to do so since all the buttons are grayed out. (see screen capture below)
I also tried simply unchecking "Android Dependencies" in "Order and Export". That had no effect on the problem.
Your suggestions are welcome.
FYI, my project has 3 main components. All 3 are contained in the same Eclipse project folder (see screen capture):
Application "App_A"
Library_L (included as Project Reference in "A") It's worth noting that Library_L executes perfectly when I run it as a non-library project.
Facebook SDK 3.0.2 (included as Project Reference in Library_L (see screen capture)
Project References are used to include a library project (e.g., the Facebook SDK).
The documentation -- and books by balding guys -- show you how to attach an Android library project to your app, and it has nothing to do with "Project References".
Similarly, the documentation for the Facebook SDK shows you how to attach their Android library project to your app (see Step 6). They follow the standard Android library project approach, and that too does not involve "Project References".
Now, it is conceivable that there's something about a newer Eclipse version (I'm running Indigo) that causes "Project References" to show Android library projects as checked -- it does not do so in my version.
Make sure that you have properly set up the Android library projects, and see if that helps with your issue.

Double facebook sdk import, in my android library project and in target project

i've a android library project that use facebook sdk, so i've linked it in my project properties.
The problem is that also the 3rd part Android application that use my library links the facebook sdk.
So the target application link facebbok and my library, and my library links to facebook sdk, finally the facebook sdk is linked twice with conflict obviously.
I check that com/facebook/android goes in my library jar.
How can i solve this double include?
Thanks to all for the support.
I faced the same problem, this is what i did. Hope it helps you too.
Remove all the libraries in your project.(Properties->javaBuildPath->library(tab)->select dependancy folder->remove)
Now go to libs and remove the library.(your project will show some errors, never mind)
Finally import the library that contains the sub library.

Categories

Resources