NoClassDefFoundError in facebook integeration - android

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.

Related

Vuforia SDK Examples Not Running - Android

I'm trying to run Vuforia SDK samples from here on Android:
I have already downloaded the main SDK and put those sample files in the sample folder. I have added the Vuforia.jar as a library and dependency to my project. The app runs on my Samsung S4 and shows the Menu but when I click Start on any of the examples it sends me back to the main menu rather than opening the camera. It doesn't show any crash error in the logs.
I'm wondering if anyone has experienced this problem and has managed to fix it?
I had the same issue and when looked at the log it had this message com.vuforia.samples.VuforiaSamples W/System.err: The library libVuforia.so could not be loaded
Then I followed the answer here https://developer.vuforia.com/forum/android/crash-start-button-sample
and that .jar file to the project. This solved the above issue.
Also I had to generate a license key for the app and set it in the last parameter in Vuforia.setInitParameters(mActivity, mVuforiaFlags, "") in the SampleApplicationSession class
try it:
add the Vuforia.jar lib in your project;
go to archive build.gradle (Module:app) and check if the variable 'VUFORIA_SDK_DIR' is correct (in my project it had the value "../../../" but i had to change to "../../"), the path has to lead to your Vuforia SDK dir;
finally, change the method Vuforia.setInitParameters in the archive SampleApplicationSession.java (line: 414), add your vuforia key in the third paramether;
it works to me

Where's gradle-installed library's source located?

In an android project, when you install library with gradle
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
Is there a way to look at the source of the library?
edit
https://developers.facebook.com/docs/android/getting-started
Talks about the sample code is included in the sdk. How do I view this sample source?
You can see the source code and the samples of Facebook Android SDK on GitHub:
https://github.com/facebook/facebook-android-sdk/
https://github.com/facebook/facebook-android-sdk/tree/master/samples
you can to initialize FB sdk 4.0 in sattings.gradle file
include ':app', 'FacebookSdk'
it will load whole SDK.
but still it gives you just iml file. it just pulls everything dynamically when called.
----------- Edit ----
I just tried rightnow,
If you are using android studio,
Just select your project explorer, as Project. generally its Android.
it that you will see whole list.
I can see facebook folder with all of its classes.
Let me know if it works for you.
Here in my project i have initialized FB SDK 4.0.

Android Studio: dx.bat failed

I am using Android Studio for building an application, in which I am using Facebook-SDK and Actionbar Sherlock as a dependencies. Each project library contains android-support-v4.jar.
When I am trying with any one of the project library it is working well. But I'm facing problems when trying to implement both simultaneously.
I know that I am facing the problem due to android-support-v4.jar.
I want to know how to add android-support-v4.jar in an efficient way.
\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat failed
I just solved the similar problem. On my case and most probably on your case also, the problem is on adding android-support-v4.jar for multiple times. I then remove the dependencies of android-support-v4.jar from my project's build.gradle and just have a single dependencies on facebook build.gradle, as facebook sdk was first to build on my project.
I faced this problem yesterday. I got it to work by making sure that there is the same android-support-v4.jar file in all libs directories throughout the project. The facebook-sdk and ABS ship with versions that might not be current when compared to the one that is installed by default by Android Studio. Let me know if it works.
If you need help integrating libraries in Android Studio, I recommend looking at facebook-sdk's step by step tutorial. I am sure once you integrate facebook-sdk you can use those steps to add any other library that you need by making small changes (i.e. use the name of the library you are trying to add instead of facebooksdk on the settings.gradle and build.gradle)

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.

Sharing project library via GIT

A colleague and I share the same android project using GIT.
Now the problem is with the shared FACEBOOK library in 'project.properties' since we do not have it on the same location.
He has it like this:
android.library.reference.1=../../facebook-android-sdk-3.0/facebook
and I have it like this:
android.library.reference.1=../facebook-android-sdk/facebook
So everytime one pulls a push from the other one has to correct the path. Is there a solution?
ps. deleting this file from the GIT repo is out of the question.
I just got into the exact same problem with FacebookSDK library.
The solution is very simple and can be easily overlooked: just add both lines to project.properties file
So your project.properties should be like this:
android.library.reference.1=../../facebook-android-sdk-3.0/facebook
android.library.reference.1=../facebook-android-sdk/facebook
Every team members can have the lib on different location. That's fine, Eclipse will ignore the unresolved lib path(s) and just use the correct one.
It works for me and seems okay for a small team.
there are 2 solutions for this:
moving the Facebook SDK to the git library and using it instead of your original FB SDK library.
adding project.properties to your git.ignore file.

Categories

Resources