简体   繁体   English

无法将Facebook SDK添加到项目

[英]Unable to add facebook sdk to project

I imported the Facebook SDK as library project into eclipse. 我将Facebook SDK作为库项目导入了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. 我尝试将现有项目导入到Workspace中 ,也将现有Android代码导入到Workspace中。

The library checkbox is checked in the properties. 在属性中选中了库复选框。 A Facebook sdk has never been imported into this workspace yet. 尚未将Facebook SDK导入此工作区。

I created a new project that runs smoothly without Facebook. 我创建了一个无需Facebook即可平稳运行的新项目。 In the properties, Android tab, I added the library project. 在属性的Android选项卡中,我添加了库项目。 It showed a green tick, but when I open that tab again, it shows a red x. 它显示了一个绿色的勾号,但是当我再次打开该选项卡时,它显示了一个红色的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. 该项目的目标是API级别19,facebook库的目标是API级别8。我还尝试了API级别10,在项目和库中都使用Java编译器1.6。

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 ; 我不明白的是,SDK附带的示例项目似乎已成功导入了SDK(绿色标记),但是它们都指向导入android上的同一问题“无法解决import android.support” 。 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 . 然后我去了Properties-> Java Build Path-> Order and Export-> clicked v4 support library复选框 So at least they work. 因此,至少他们可以工作。 Why do they successfully load the Facebook SDK and why is my app unable to do it? 他们为什么成功加载Facebook SDK,为什么我的应用程序无法加载?

The Facebook SDK has no libs folder so I guess an interference between different v4 support libraries is out of the question. Facebook SDK没有libs文件夹,因此我猜想不同v4支持库之间的干扰是不可能的。

I have tried this on two different computers as well. 我也在两台不同的计算机上尝试过此操作。

在此处输入图片说明

在此处输入图片说明

I decided to install Android from step to step instead of the ADT Bundle. 我决定逐步安装Android而不是ADT捆绑包。 I downloaded Eclipse Juno for Java Developers, installed the newest Java version (1.8) and installed the Android packages. 我为Java开发人员下载了Eclipse Juno,安装了最新的Java版本(1.8),并安装了Android软件包。 Created a new project and imported the facebook sdk 3.5 (tried 3.0.2 and 3.8 as well). 创建了一个新项目并导入了Facebook sdk 3.5(也尝试了3.0.2和3.8)。 I still get the red X. 我仍然得到红色的X。

I appreciate any help. 感谢您的帮助。

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. 诀窍是您需要将库与项目放在同一驱动器上,该驱动器通常是C:驱动器。 That's all. 就这样。 Thank you Facebook for not notifying us about this.. 感谢您的Facebook通知我们。

Solved. 解决了。 Here is what I did to solve this strange error. 这是我为解决此奇怪错误所做的工作。

  1. Copy the contents of project.properties file. 复制project.properties文件的内容。
  2. Delete project.properties file. 删除project.properties文件。
  3. Create a new file and name it project.properties 创建一个新文件并将其命名为project.properties
  4. Paste the contents of the previous file into this new file. 将先前文件的内容粘贴到此新文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM