Unable to add facebook sdk to project

2019-09-14 19:54发布

问题:

I imported the Facebook SDK as library project into eclipse. I did it by checking Copy projects into Workspace and by leaving it unchecked as well (for some reason the description says that I must uncheck it).

I tried importing Existing Projects into Workspace and Existing Android Code Into Workspace as well.

The library checkbox is checked in the properties. A Facebook sdk has never been imported into this workspace yet.

I created a new project that runs smoothly without Facebook. In the properties, Android tab, I added the library project. It showed a green tick, but when I open that tab again, it shows a red x. The target of the project is API level 19, the target of the facebook library is API level 8. I also tried it with API level 10 I am using Java compiler 1.6 in both the project and the library.

What I don't understand is that the sample projects that came with the SDK seem to have successfully imported the SDK (green tick), however they all point to the same problem "The import android.support cannot be resolved" on import android.support.v4.app.FragmentActivity; I had to hover over the line and click Fix Project setup to make them work. Then I went to Properties -> Java Build Path -> Order and Export -> clicked v4 support library checkbox. So at least they work. Why do they successfully load the Facebook SDK and why is my app unable to do it?

The Facebook SDK has no libs folder so I guess an interference between different v4 support libraries is out of the question.

I have tried this on two different computers as well.

I decided to install Android from step to step instead of the ADT Bundle. I downloaded Eclipse Juno for Java Developers, installed the newest Java version (1.8) and installed the Android packages. Created a new project and imported the facebook sdk 3.5 (tried 3.0.2 and 3.8 as well). I still get the red X.

I appreciate any help.

回答1:

I ran into this issue half a year later and my earlier answer was of no help. The trick is that you need to have the library on the same drive as your project, which is usually the C: drive. That's all. Thank you Facebook for not notifying us about this..



回答2:

Solved. Here is what I did to solve this strange error.

  1. Copy the contents of project.properties file.
  2. Delete project.properties file.
  3. Create a new file and name it project.properties
  4. Paste the contents of the previous file into this new file.