Eclipse 上的 Android Facebook SDK 配置
我下载了android的facebook sdk,但到目前为止我无法正确配置。 Eclipse 无法将 facebook sdk 识别为项目。
有人遇到这个问题吗?
I downloaded the android's facebook sdk but so far I couldn't configure properly. Eclipse doesn't recognize the facebook sdk as a project.
Does anyone got this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该使用 git 插件将 facebook 项目从 github 导入到 Eclipse 工作区中。它被配置为 android 库。然后在你想要使用该库的 android 项目中。右键单击该项目并选择属性。单击 Android 选项卡,底部应该是库部分,详细说明
You should use the git plugin to import the facebook project from github into your eclipse workspace. It's configured as an android library. And then in your android project in which you want to use the library. Right click on the project and choose properties. Click on the Android tab, and at the bottom should be a section for libraries, detailed instructions here. Click Add, and the facebook sdk should appear. Check the facebook sdk and it will then be available in your app.
Facebook SDK 集成到 Android 应用程序应该很容易,但在第一个集成步骤中需要注意一些注意事项,因此请仔细遵循:
从 git hub 下载 SDK - 这可以使用 github 客户端来完成,但更简单的方法是只需按“zip”按钮即可下载压缩版本,如下面的快照所示。
解压 zip 文件 - 确保将其解压到 <不在 Eclipse 工作区中。在下一步中,您将需要在 Eclipse 中基于此 zip 创建一个项目,但有时,将提取的 zip 直接放入工作区会混淆 Eclipse,因此请避免将其放在那里。将其放在其他地方。
打开 Eclipse 并为 Facebook Android SDK 源创建一个新的 Android 项目(文件 -> 新建 -> 项目 -> Android 项目)。 (在下一步中,您将其作为参考库添加到您的应用程序中)。通过选择“从现有源创建项目”来创建项目,并指定将 zip 解压缩到的 facebook-sdk 文件夹。
(注意:如果您希望将其存储在工作区本身中,您可以稍后将项目“导入”到工作区中)
通过选择(您的应用程序的)当前项目将其作为项目库添加到您的应用程序 ->属性,并将 facebook 项目作为库添加到您当前的项目中。
后续步骤包括向 Android Manifest 添加权限,例如
uses-permission android:name="android.permission.INTERNET"/>
然后将您的应用程序 ID 添加到代码中。我将跳过此处的详细信息,因为它非常简单。
Facebook SDK integration into an android application should be easy, but there are some caveats to take care of during the first integration steps, so follow it carefully:
Download the SDK from git hub - This could be done using a github client, but an easier way is to simply download the zipped version by pressing the "zip" button as appears in the following snapshot.
Extract the zip file - make sure to extract it into a folder that is not within the eclipse workspace. In the next step you will need to create a project in eclipse based on this zip, but sometimes, putting the extracted zip directly into the workspace confuses eclipse, so avoid putting it there. Put it somewhere else.
Open Eclipse and create a new Android Project (File -> New -> Project -> Android Project) for the Facebook Android SDK source. (On the next step you will add it as a reference library to your app). Create the project by selecting "Create project from existing source" and specify the facebook-sdk folder into which you extracted the zip.
(note: if you want it to be stored in the workspace itself, you can always "import" the project into the workspace later on)
Add it as a project library to your app by selection the current project (of your app) -> properties, and add the facebook project as a library to your current project.
later steps include adding permissions to the Android Manifest such as
uses-permission android:name="android.permission.INTERNET"/>
and then adding your application ID into the code. I will skip the details here as it is quite straight forward.
以下步骤用于创建 facbook-android.jar(在您的任何项目中使用此 jar 文件)
第 1 步:从 github 下载 Facebook Android SDK。
第二步:提取它。 (在任何地点)。
第三步:在 Eclipse 中使用“从现有源创建项目”选项创建新项目
第四步:输入项目名称“com_facebook_android”。
第五步:将位置设置为提取位置中的“facebook”文件夹。
第六步:单击“完成”。
第七步:在项目资源管理器中选择“com_facebook_android”项目,然后右键单击
选择导出选项。
第 8 步:在导出向导中选择 Java 文件夹中的 JAR 文件。
第九步:单击“下一步”,然后浏览 jar 文件的位置,并根据您的意愿命名,例如“facebook-android.jar”
Step10: 单击完成........ JAR 文件将在该位置创建
这不是正确的过程,您应该使用 facebook-android 项目作为库项目,因为资源文件不会导入到您的项目中您使用的 .jar 文件
jar 文件仅适用于 Java 项目,不适用于 Android 项目,某些 jar 文件可能有效,但并非全部有效。
following steps are for creating facbook-android.jar (use this jar file in your any project)
Step1: Download Facebook Android SDK from github.
Step2: Extract it. (at any location).
Step3: In Eclipse create new project using create project from existing source option
Step4: Enter the project name as "com_facebook_android".
Step5: Set Location to "facebook" folder in extracted location.
Step6: Click Finish.
Step7: Select the "com_facebook_android" project in project explorer and right click
select export option.
Step8: In the export wizard select JAR file in Java folder.
Step9: Click next then browse the location for jar file and give the name as yor wish like "facebook-android.jar"
Step10: Click finish........ JAR file will be created in that location
This is not correct process, you should use facebook-android project as library project, because resource files will not import to your project while you are using .jar file
jar file is only for Java Projects not for Android Project, Some of jar files may work but not all..