Eclipse中的Android SDK SDK 4 [英] Android Facebook SDK 4 in Eclipse

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

问题描述

有没有办法将Android的新的Facebook SDK导入到没有Gradle或Maven的Eclipse(像以往那样)?我一直在看一些页面,但我没有找到方法。



谢谢

解决方案

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



步骤1.导入到Eclipse



首先,下载。



下载后,您可以在Android sdk文件夹中找到它:< sdk> / extras / android性/支撑性/ V4 。然后将其添加到facebook SDK项目中:右键单击SDK项目 - > 属性 - > Java构建路径 - > - > 添加外部JAR,然后选择 android-support-v4.jar 从它的文件夹。







之后很多的错误将会消失:





但是,还有其他错误。所以我们要去另一个类,发现它的错误代码片段。在其上移动鼠标指针,Eclipse将显示您所面临的是什么样的错误提示。它表示您的符合性Java必须是1.7版本。允许Eclipse通过点击更改项目...,或通过转到属性手动执行此操作 - > Java Complier - > 编译器编译级别 - > 1.7









向前移动。现在我们只面对一种错误,那就是FB SDK找不到所需的Bolts Android库。





我们要google,发现它在,并设置您的Android应用程序项目(不要忘记将所有必需元素添加到Manifest.xml)。您可以使用本教程将LoginButton添加到您的活动中。尝试建立它。它应该运行没有问题。




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.

Thanks

解决方案

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

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.

Step 2. Fixing errors

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

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

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.

After that a lot of errors will be gone:

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

OR

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

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!

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

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.

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中的Android SDK SDK 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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