Android Facebook Sdk 4 in Eclipse

Facebook SDK v.4 for Android: errors on Eclipse

I did some more tests and find out that by downloading the two libraries:

android-support-v4.jar
bolts-android-1.1.2.jar

from the github project (https://github.com/facebook/facebook-android-sdk) did the trick.

So the steps are the following:

  1. Download, unpack and import as android existing code into workspace the latest v.4 version of the Facebook SDK for Android.

  2. Download the two jars from GitHub

  3. Set the Facebook Project as "isLibrary"

  4. Add the two jars as "external jars" in the classpath

  5. Set the java compiler to 1.7

  6. clean and rebuild the project

Now errors are gone.

Android Facebook SDK 4 in Eclipse

I also have faced this problem, so I will write a short guide, how to install it in Eclipse.

Step 1. Import to Eclipse

First of all, download the latest version of SDK (on current moment it is 4.0). Unzip it to a folder.

Open Eclipse, click the right mouse button in "PackageExplorer" and choose "Import". After that, go to "Android" -> "Existing Android Code Into Workspace".

Sample Image

Now click "Browse" and choose unzipped SDK folder, and deselect all other found projects, except from the "facebook" (it is an SDK). Other included projects are just samples, and you don't need them now.

Sample Image

You may select "copy project to workspace" checkbox, if you need this.

Step 2. Fixing errors

After importing, we will see, that the whole facebook SDK package are in errors:

Sample Image

But if we look closer, and open one of marked as error classes, we will find, that SDK tried to importsupport.v4 library:

Sample Image

It required for properly compilation. You can find instructions how to download it using Android SDK Managerhere.

After it downloading, you can find it in your Android sdk folder: <sdk>/extras/android/support/v4. Then add it to the facebook SDK project: right mouse click on SDK project -> "Properties" -> "Java Build Path" -> "Libraries" -> "Add External JARs", and choose android-support-v4.jar from it's folder.

Sample Image
Sample Image
Sample Image

After that a lot of errors will be gone:

Sample Image

But, there are other errors. So we are going to another class, and found it error code piece. Move mouse pointer on it, and Eclipse will show you the hint, of what kind of error you are facing. It says that your compliance Java must be version 1.7. Allow Eclipse do it by clicking "Change project ...", or do it manually by going to "Properties" -> "Java Complier" -> "Compiler compilance level" -> "1.7".

Sample Image

OR

Sample Image

Moving ahead. Now we are facing only one kind of error, that says that the FB SDK can't find required Bolts Android library.

Sample Image

We are going to google, found it compiled jar in a repository. Choose the latest version (for current moment it's 1.2.0, but SDK gradle file is using 1.1.4, so you may choose that), and download the jar.
Now add it to the facebook SDK as external lib, as we do it before.

Sample Image

Voila! Ther are no errors anymore!

Sample Image

Also don't forget to set in the facebook SDK project "Properties" -> "Android", that it is a Library.

Sample Image

Just for ensurance, close/re-open the SDK project and clean it ("Eclipse menu" -> "Project" -> "Clean"), so all files can build properly.

Step 3. Add it to the Android project

Now you can try to add it to your Android app. Go to your Android app project "Properties" -> "Android" -> "Library" -> "Add", and choose facebook SDK.

Sample Image

Follow official tutorial, and set up your Android application project (don't forget to add all required elements to Manifest.xml). Than you can use this tutorial to add LoginButton to your Activity. Try to build it. It should run without problem.

Sample Image

android facebook sdk v4.0 not working

The Facebook Android SDK v4.0 uses Gradle as it's build and dependency management system. http://marketplace.eclipse.org/content/gradle-integration-eclipse-44 is available for Eclipse. Also http://eclipse.org/m2e/ can be used for integrating with the Facebook's maven artifact: http://search.maven.org/#artifactdetails|com.facebook.android|facebook-android-sdk|4.0.0|

The android:textAllCaps issue occurs if you're targeting a version smaller than API 15. This doesn't cause a build issue in Gradle, and the lint warning is suppressed as it's ignored in API versions < 15.

Facebook SDK 4.8.2 import in ECLIPSE

Here you have an answer from Android Facebook SDK 4 in Eclipse

I also have faced this problem, so I will write a short guide, how to
install it in Eclipse.

Step 1. Import to Eclipse

First of all, download the latest
version of SDK (on current moment it is 4.0). Unzip it to a
folder.

Open Eclipse, click the right mouse button in "PackageExplorer" and
choose "Import". After that, go to "Android" -> "Existing Android
Code Into Workspace"
.

Sample Image

Now click "Browse" and choose unzipped SDK folder, and deselect all
other found projects, except from the "facebook" (it is an SDK).
Other included projects are just samples, and you don't need them now.

Sample Image

You may select "copy project to workspace" checkbox, if you need this.

Step 2. Fixing errors

After importing, we will see, that the
whole facebook SDK package are in errors:

Sample Image

But if we look closer, and open one of marked as error classes, we
will find, that SDK tried to importsupport.v4 library:

Sample Image

It required for properly compilation. You can find instructions how to
download it using Android SDK Managerhere.

After it downloading, you can find it in your Android sdk folder:
<sdk>/extras/android/support/v4. Then add it to the facebook SDK
project: right mouse click on SDK project -> "Properties" -> "Java
Build Path"
-> "Libraries" -> "Add External JARs", and choose
android-support-v4.jar from it's folder.

Sample Image Sample Image
Sample Image

After that a lot of errors will be gone:

Sample Image

But, there are other errors. So we are going to another class, and
found it error code piece. Move mouse pointer on it, and Eclipse will
show you the hint, of what kind of error you are facing. It says that
your compliance Java must be version 1.7. Allow Eclipse do it by
clicking "Change project ...", or do it manually by going to
"Properties" -> "Java Complier" -> "Compiler compilance level"
-> "1.7".

Sample Image

OR

Sample Image

Moving ahead. Now we are facing only one kind of error, that says that
the FB SDK can't find required Bolts Android library.

Sample Image

We are going to google, found it compiled jar in a repository.
Choose the latest version (for current moment it's 1.2.0, but SDK
gradle file is using 1.1.4, so you may choose that), and download the
jar. Now add it to the facebook SDK as external lib, as we do it
before.

Sample Image

Voila! Ther are no errors anymore!

Sample Image

Also don't forget to set in the facebook SDK project "Properties" ->
"Android", that it is a Library.

Sample Image

Just for ensurance, close/re-open the SDK project and clean it
("Eclipse menu" -> "Project" -> "Clean"), so all files can build
properly.

Step 3. Add it to the Android project

Now you can try to add
it to your Android app. Go to your Android app project "Properties"
-> "Android" -> "Library" -> "Add", and choose facebook SDK.

Sample Image

Follow official tutorial, and set up your Android application
project (don't forget to add all required elements to Manifest.xml).
Than you can use this tutorial to add LoginButton to your
Activity. Try to build it. It should run without problem.

Sample Image

This also might be helpful, if you find any issue: Facebook SDK v.4 for Android: errors on Eclipse

Check also: Android Facebook SDK configuration on Eclipse

Hope it help


EDIT: As you would see in the comments below, this answer is not already corrected. The best way to deal with this problem is export project from Eclipse to Android Studio, which doesn't have this issue and becoming the first Android Developer tool, where Eclipse seems to be as was said on Android Dev Summit 2015 truly deprecated.

How to import facebook sdk, version 4.2.0 in eclipse?

To import the new Facebook SDK you should it from https://developers.facebook.com/docs/android

-Then when you download it, copy the following folder to your proyect directory:
facebook

-Import the proyect to your workspace.

-Add the Facebook SDK as Library in eclipse. Right Click on your proyect-->properties--> Android and add it as library.

Thats all!

How to Import Facebook SDK to Eclipse

You may need to include the annotations.jar file into your project, but note that there are two annotations.jar files in your Android SDK:

android-sdk/tools/support/annotations.jar - Which includes the following annotations:

SupportLint

TargetApi

android-sdk/extras/android/support/annotations/annotations.jar - Which includes many other annotations:

AnimRes

AnimatorRes

AnyRes

ArrayRes

AttrRes

BoolRes

ColorRes

DimenRes

DrawableRes

FractionRes

IdRes

IntDef

IntegerRes

InterpolatorRes

LayoutRes

MenuRes

NonNull
Nullable

PluralsRes

RawRes

StringDef

StringRes

StyleRes

StyleableRes

XmlRes

You need to import second one as the highlited is lies in second list.



Related Topics



Leave a reply



Submit