在Eclipse的Andr​​oid的Facebook SDK 4 [英] Android Facebook SDK 4 in Eclipse

查看:192
本文介绍了在Eclipse的Andr​​oid的Facebook SDK 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一些方法来导入新的Facebook SDK为Android,而无需摇篮或Maven(有点像过去的方式)的Eclipse?我一直在看一些网页,但我没有找到一个方式。

Are there some way to import the new Facebook SDK for Android to Eclipse without Gradle or Maven (something like the past way)? I've been watching some pages but i don't find a the way.

感谢

推荐答案

我也遇到这个问题,所以我会写一个简短的指南,如何在Eclipse中安装。

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

首先,下载最新版本的SDK (当前时刻它是4.0)。它解压缩到一个文件夹。

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

打开Eclipse,点击鼠标右键,在PackageExplorer,选择导入。在此之后,转到机器人 - > 现有的Andr​​oid code进入工作区

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

现在点击浏览并选择解压缩SDK文件夹,并取消其他所有发现项目,除了从脸谱(这是一个SDK)。其他项目包括只是样品,你现在不需要它们。

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.

您可以选择复制项目工作区复选框,如果你需要这个。

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

导入后,我们会看到,整个Facebook的SDK包是错误的:

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

但是,如果我们仔细看,并打开标记为错误类之一,我们会发现,该SDK试图导入 support.v4库

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

这需要正确编译。你可以找到关于如何使用下载它 Android的SDK管理器这里

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

它下载后,你可以在你的Andr​​oid SDK文件夹中找到它:< SDK> /演员/安卓/支持/ V4 。然后将其添加到Facebook的SDK项目:鼠标右键点击SDK项目 - > 属性 - > Java构建路径 - > - > 添加外部JAR,并选择 Android的支持 - v4.jar 从它的文件夹中。

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.

在一个很多错误将会消失:

After that a lot of errors will be gone:

但是,也有其他的错误。因此,我们要到另一个类,并发现它的错误code片。将其上的鼠标指针,和Eclipse会告诉你的提示,什么样的错误你正面临着​​。它说,你的合规性的Java必须是1.7版本。允许Eclipse中点击更改项目...做到这一点,或者做手工转到属性 - > 的Java编者 - > 编译器compilance水平 - > 1.7

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

展望未来。现在,我们正面临着只有一种错误,即说,FB SDK找不到所需的螺栓的Andr​​oid库。

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

我们都将谷歌,发现它编译罐子在。选择最新的版本(当前时刻是1.2.0,但SDK摇篮文件使用1.1​​.4,所以你可以选择),并下载JAR。 现在把它添加到Facebook的SDK外部LIB,就像我们以前做的。

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.

瞧!疗法是没有错误了!

Voila! Ther are no errors anymore!

另外别忘了在Facebook的SDK项目设置属性 - > 机器人,它是一个库

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

只是为了ensurance,关闭/重新开放了SDK项目,清洁(Eclipse菜单 - > 项目 - > 清洁),因此所有的文件都可以正常建立。

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

现在,你可以尝试将其添加到你的Andr​​oid应用程序。转到您的Andr​​oid应用项目属性 - > 机器人 - > - > 添加,并选择Facebook的SDK

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.

官方教程,并设置你的Andr​​oid应用程序项目(不要忘记添加所有必需元素的Manifest.xml)。比你可以使用本教程,以LoginButton添加到您的活动。尝试建立它。它应该运行没有问题。

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.

这篇关于在Eclipse的Andr​​oid的Facebook SDK 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆