java.lang.NoClassDefFoundError: com.facebook.android.Facebook
Solution 1
Just go to Project / Properties / Java Build Path / Order and Export and click on jar's checkbox. This will set jar as "exported". You can verify this in .classparh file: classpathentry exported="true" kind="lib" path="/my-jars/facebook-android-sdk-1.2.1.jar"
Don't forget to clean your project after that (Project / Clean...)
Solution 2
I heard that with the latest ADT you need to name your library folder "libs" and not "lib". But that didn't work for me.
So instead I had to resort to moving my jar file into the "assets" folder. That fixed my problem.
Completely retarded if you ask me.
Solution 3
I keep getting this issue too, the "Library Projects" (which should contain the com_facebook_android.jar) is not reflected in the "Package explorer" at all. But It is easily solved.
Right click on project>Properties>Android> Library -> remove the facebook library project added -> apply.
Then add the facebook library project again and click apply. This time "Library Projects" will come up in your Package Explorer on the right side.
Solution 4
Have you recently updated your ADT or Android SDK? Try deleting the reference to the facebook library or facebook jar and re-adding it.
They changed the way they handle external libraries references in the latest ADT updates, and it's thrown off a ton of my projects. Deleting the references and re-adding them seems to do the trick.
user983965
Updated on June 20, 2022Comments
-
user983965 almost 2 years
I keep getting the error java.lang.NoClassDefFoundError: com.facebook.android.Facebook when running my application.
This occurs when calling:
facebook = new Facebook(APP_ID);
Addtional error message:
Could not find class 'com.facebook.android.Facebook', referenced from method com.example.example1.ShareOnFacebook.onCreate
I have add the facebook .jar file via Referenced libraries in Eclipse.
Has anyone encountered/solve this problem?
-
Dimon over 11 yearsbest solution of the problem