2

How to import facebook sdk 4.8.2 in eclipse. I am unable to import as facebook folder contains aar file when we directly download developer site. And from git , unable to get src files of facebook

Rummy
  • 117
  • 2
  • 9
  • go through this link you will got solution : http://stackoverflow.com/questions/29379890/android-facebook-sdk-4-in-eclipse – Kapil Rajput Dec 22 '15 at 10:11
  • Thanks but latest facebook sdk contains facebook folder which has aar file which cannot be imported. – Rummy Dec 22 '15 at 10:23
  • The Latest SDK is in gradle structure. I think we have to use android studio. So may be we can't use latest sdk for eclipse IDE – Rummy Dec 22 '15 at 10:35

2 Answers2

3

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".

enter image description here

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.

enter image description here

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:

enter image description here

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

enter image description here

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.

enter image description here enter image description here enter image description here

After that a lot of errors will be gone:

enter image description here

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".

enter image description here

OR

enter image description here

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

enter image description here

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.

enter image description here

Voila! Ther are no errors anymore!

enter image description here

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

enter image description here

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.

enter image description here

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.

enter image description here

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.

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • Thanks but latest facebook sdk contains facebook folder which has aar file which cannot be imported – Rummy Dec 22 '15 at 10:23
  • Maybe this would be useful: http://stackoverflow.com/questions/21417419/how-to-convert-aar-to-jar – piotrek1543 Dec 22 '15 at 10:31
  • On last Android Dev Summit 2015 was announced that Eclipse is deprecated. Try to import your Eclipse project to Android Studio or you would face more and more Eclipse ADK issues – piotrek1543 Dec 22 '15 at 10:33
  • 1
    The Latest SDK is in gradle structure. I think we have to use android studio. So may be we can't use latest sdk for eclipse IDE – Rummy Dec 22 '15 at 10:35
  • You said: Gradle structure. Next argument to use Android Studio ;-) – piotrek1543 Dec 22 '15 at 10:43
  • Yes you are correct. I have to migrate my project. Thanks – Rummy Dec 22 '15 at 11:02
  • Thank you so much! I'm still procrastinating migrating from Eclipse to Android Studio. And I found that the last version that works with Eclipse would be Facebook Android SDK 4.5.1. Download link here: https://origincache.facebook.com/developers/resources/?id=facebook-android-sdk-4.5.1.zip Following this instructions make it work! – marcwjj Apr 08 '16 at 08:30
  • Both Eclipse and Facebook SUCK. This errors are unacceptable. Great answer though. – Josh Jul 14 '16 at 21:41
0

Thank you so much! I'm still procrastinating migrating from Eclipse to Android Studio. And I found that the last version that works with Eclipse would be Facebook Android SDK 4.5.1. Download link here: https://origincache.facebook.com/developers/resources/?id=facebook-android-sdk-4.5.1.zip

Following this instructions make it work!

marcwjj
  • 1,705
  • 1
  • 12
  • 11