This open source Java library allows you to integrate Facebook into your Android application. Except as otherwise noted, the Facebook Android SDK is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)
This library includes two sample applications to guide you in development.
simple: A bare-bones app that demonstrates authorization, making API calls, and invoking a dialog.
stream: This slightly beefier application lets you view your news feed.
To install a sample application into Eclipse (3.5):
- Create the sample application in your workspace:
- Select File -> New -> Project, choose Android Project, and then click Next.
- Select "Create project from existing source".
- Choose either examples/simple or examples/stream. You should see the project properties populated.
- Click Finish to continue.
Build the project: from the Project menu, select "Build Project".
Run the application: from the Run menu, select "Run Configurations...". Under Android Application, you can create a new run configuration: give it a name and select the simple Example project; use the default activity Launch Action. See http://developer.android.com/guide/developing/eclipse-adt.html#RunConfig for more details.
Here are some tips to help test your application:
You will need to have the Facebook application in your test environment. The SDK includes a developer release of the Facebook application that can be side-loaded for testing purposes. On an actual device, you can just download the latest version of the app from the Android Market, but on the emulator you will have to install it yourself:
adb install FBAndroid.apk
Use a signed build. You can sign with a debug key, but make sure that the key you used to sign matches the Key Hash field in the Facebook developer settings.
Make sure to test both with and without the Facebook application. The SDK will fall back to a Webview if the Facebook app is not installed.
You can use this guide to developing on a device.
Here's a few common errors and their solutions.
Build error: "missing gen files".
This should go away when you rebuild the project. If you have trouble, try running Clean... from the Project menu.
This error means that the Facebook server doesn't recognize your Android key hash. Make sure that you correctly generated and copy/pasted your key hash into the Facebook developer settings console (http://www.facebook.com/developers/apps.php), and make sure that your application has been signed with the same key you registered with Facebook.
Dialog won't load or shows a blank screen.
This can be tricky to debug. If the logs don't give an indication of what's wrong, I suggest installing tcpdump on your device and getting a trace. Tutorial: http://www.vbsteven.be/blog/android-debugging-inspectin-network-traffic-with-tcpdump/
If you still can't tell what's going on, then file an issue and please include the HTTP trace.
I can't upload photos with photos.upload.
Make sure the Bundle value for the photo parameter is a byte array.