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.
Right click on the Project. Choose Properties -> Android. Under Library click on the Add... button and select the path to the Facebook SDK Project.
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.
I managed to overcome this error by doing a clean build for both my project and facebook library (referenced) project.
The steps:
On Eclipse:
1) Select Project -> Clean
2) Select both your project and facebook sdk project
3) select OK
I too faced the same problem. I was able to overcome this issue by placing the Facebook SDK library as well as my project(to which I want to link the Facebook SDK) within the same workspace. Now go to your project->right click->properties->android->scoll down->add->select the path to facebook SDK->press ok.
This way you can link the Facebook SDK to your project. Only adding the Facebook jar will result in an exception as this does not contain all the classes.
I also had this exception and tried almost everything i found. But then i copied the facebook sdk project to my workspace folder and then referenced it from there in my project and it worked.
Don't know why this happened, this made no sense to me as i was providing it the path while adding reference but anyways, It solved the problem.
I had this same problem. I solved it just by following these steps:
Remove all the sample projects and the Facebook SDK from Eclipse
Import the SDK and sample projects again, but this time, using the "Copy projects into workspace" option checked.
Rebuild the SDK and the sample projects
Working!
Try to mark the check-boxes in Properties -> Java Build Path -> Order and Export.
I had the same problem with the UiLifecycleHelper, and checkig both the Android Dependencies and the android-support-v4.jar worked perfectly. Better to run a clean after that.
I had similar problems. I am building one my lib project (with activities) and my main project using this lib. I had these problems. I had added the lib under the Project properties/Android section and at the bottom, as suggested correctly before, but this wasn't enough (note that both projects were compiling good). I had to change the lib project and use the full path to the layout as:
setContentView(com.example.mylib.R.layout.activity_main1);
Note that using just R.layout wasn't enough, although I have defined the:
import com.example.mylib.R;
Valid alternative is however:
import com.example.mylib.R.layout;
setContentView(layout.activity_main1);
Using Eclipse.
hth to someone
download bolts-android1.1.2 and put into \libs folder. then open the project properties-> java Build Path-> Project tab , Add Facebook SDK. (Facebook SDK libs must be attached with project)
The new facebook SDK already had android.support.V4.jar.
And when you create a new android application, even that contains one.
Hence when you check the console, you get error message called JAR mismatch.
In that case select properties of android project -> Java Build path ->
Select Library tab -> Remove android.support.V4.jar
Select Order and Export and uncheck -> Reference libraries (android.support.V4.jar)
This will fix the issue.
Related
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?
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...)
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.
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.
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.
A solution that worked for me:
the android-support-v4.jar file inside my project had a different version from the one inside facebook's project. So I copied facebook's support lib to my project libs folder and it worked like a charm.
I ma trying to open the source code of Gallery2 application in of Android in Eclipse and for some reason I am not able to open it.
I did Open> Android project from the existing code and selected the Gallery2 folder that I downloaded. As soon as I do that, i see the following screen:
As we can see that next button is disabled, Finish button is disabled and it says "Select atleast one project even though the project is selected". I am not sure what to do.
Or let me ask the question another way. I have successfully imported project into my workspace. What do I do now? I am fron Visual Studio world and ideally I should be looking for a solution file and that will open the entire project. How does that happen with java Android file?
Any ideas?
Because there is already project whose name is same GalleryActivity/Gallery2 or project which have same package name already imported in your eclipse workspace.
Check all the imported projects in your eclipse project explorer
This similiar error happened to me when I imported a standard Java project, I knew it was a java project but Eclipse didn't think so. It turned out that my project was missing the project.properties file and because of that Eclipse didn't recognize my project as a Java project. In the end I imported it as default project and added java facets to it, that did the trick. I don't know if this is your case but it may be worth to have a look at it, eclipse is a bit pedantic when it comes to things like this.
you have already imported same named project in your workspace. so first check your workspace and if exists delete it. or create another workspace and try to import the project
I am trying to run a project but there is a red exclamation mark over the project name. When checked in Problems, its throwing an error "project is missing required library". The library is pointed to android.jar located in some path. When checked in package explorer, I found the android.jar in Android 2.3.1 folder structure of project in package explorer. The android.jar located in Android 2.3.1 folder is pointing to some other path. Is the build error occurring due to the difference in paths for android.jar files? I have imported the project.So, how should I modify the path which is shown in the problems window? I am newbie to android and so pls help me.
Thanks!!!
The easiest way to resolve this common problem is to re-associate your project with an SDK version. You do this by opening project properties, clicking on Android, select a different SDK version to that which is currently selected (if one is selected at all), click okay, and then repeat the process to switch back to the desired SDK version, if desired.
I tried Phillip's answer and it didn't work in my case. Another place to look is opening project properties and clicking on "Java Build Path" -- if your project used some external JARs, check to make sure the links haven't been broken. If they have, reimport them again and remove the missing ones.
Import your library through the option: File/ Import... / Android / Existing Android Code Into Workspace, and not by creating a New Project and referencing the other (if you did this way).
I had this same problem and solved that way. As example, there is a PDF which demonstrates how to import other projects [Look at the page 28] (The material are in Portuguese)
I am working with Android API 17 on eclipse Indigo. I have cloned the faccebook sdk from github and done the facebook library project set up using the source project provided in the fb sdk.
Now I'm trying to include this library project in my android demo project. I have added it under Project properties->Android->Library section. Im seeing green color tick mark infront of the added library.
Also, i have added the same in the Project properties->Java build path->Projects.
build is successful. but when i try to install on my AVD, im getting the error, E/AndroidRuntime(748): java.lang.NoClassDefFoundError: com.facebook.android.Facebook
Can anybody plz help me how to fix this issue.
---- EDIT ------
One more thing I have observed is, when i opened Project properties->Android window, the green tick mark is not displaying under Library section, instead I'm seeing red cross mark.
Any ideas?
Thanks,
Venkat Papana
Same thing happen for me also.. try below .. it will work..
A Best way to add External Jars to your Android Project or any Java project is:
Create a folder called libs into you project root folder
Copy your Jar files to the libs folder
Now right click on the Jar file and then select Build Path > Add to Build Path, this will create a folder called Refrenced Library into you project, and your are done
By do doing like this, whenever you transfer you project to other Computer, you will not miss your libraries which are being referenced to some space on your Hard drive.
(The facebooksdk.jar can be found at the facebook-sdk directory: <facebook-sdk>\facebook\bin)
i know this question is old But I thought that may be it can help someone.
Move the library project and the application on the same drive. Usually this is a bug in Eclipse.
I solved my problem by moving them in same drive on my computer.
You can Give it a try.
You need to make both project in same dictionary then include it using Project Properties -> Android-> Library.
This works fine.
You do not have to add this to the library project as this is not the library.
https://github.com/facebook/facebook-android-sdk is the help of the project ad the sample code for the including the project in our code. Just you need to create the app ID for the facebook by registering your api with it.
Hope this will help you in your project.
Resolved by copying the com.facebook.android source code to my project source.
In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed