Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android facebook SDK doing error java.lang.NoClassDefFoundError‎

I have just downloaded the facebook SDK from http://github.com/facebook/facebook-android-sdk I unpack it from git and opened Eclipse. I then created a new project using existing source and selected the facebook directory. So the sdk project came up correctly (i think). Then I created a new project again using existing source and selected the "Simple" example. Its came up with errors. I went in the properties and selected Build Path section and added the facebook SDK project and applyed. All the errors disappear. I then tried to run the Example but im getting an exception on the first call to facebook SDK function ! Exception is NoClassDefFoundError. Its seems that at runtime it cannot find the class of the SDK. How come ? Any suggestions ? Someone did sucessfully run this example ? Any help would be greatly appreciated.

like image 307
Fabien Avatar asked Aug 25 '10 07:08

Fabien


2 Answers

Right click on the Project. Choose Properties -> Android. Under Library click on the Add... button and select the path to the Facebook SDK Project.

like image 52
Dumitru Hristov Avatar answered Oct 31 '22 19:10

Dumitru Hristov


I had your same problem, and there was a suggestion in another question thread to export the Android Facebook SDK as a jar file and add that file to your project.

Although some people said that the previous solution worked with them, it didn't work with me!

The only thing worked with me is: coping the Android Facebook SDK six classes into my project and that solved my problem.

Steps:

1- I simply copied the following 6 classes from the Android SDK into my project AsyncFacebookRunner.java DialogError.java Facebook.java FacebookError.java FbDialog.java Util.java

2- I've also copied the facebook_icon.png file from the drawable folders to my drawable folders.

3- I imported my R.java class in the the copied FbDialog.java class.

My advice is to try the jar solution first (as it is the neat way to be a developer), if it didn't work with you, then try my solution (as it is a way to solve the problem).

Thanks and hopefully it will solve your problem.

Mohamed.

like image 39
Mohamed A.Karim Avatar answered Oct 31 '22 18:10

Mohamed A.Karim