There has been a lot of fuss about creating a facebook app, especially for Android because it requires additional ‘key hashes’. With the updated facebook interface, some may not be familiar with it. Here is a quick step by step picture tutorial to get everything up and running.
Add & Create New App ID
First off, we will need to create a facebook app. Login into your facebook account or go straight to ‘developers.facebook.com‘. On the top-right hand corner, select “Create App”. A new page will appear.
Next, select “Apps” followed by “Create a new app”. A pop-out box will appear.
Here are what the fields mean.
Display Name – This will be the name of the app, which other people will see. This is usually filled with the company name, application name, or a brand name.
Namespace – As an option, this is a unique identifier for the app.
Category – There are around 20 choices for you to select the category of the app.
In this tutorial, the “Display Name” used is “Sushi Rice” in the category of “Food & Drinks”. After submitting, you may be required to enter a CAPTHA.
Adding Android Platform to the New App
You will then be brought to the “Dashboard” which shows an overview of the whole facebook app. Take note of the “App ID’, which is a 15 digit long number. This will be used in your Android mobile application later.
Goto the “Settings” page. There, click “Add Platform” and select Android.
A new box will appear for you to fill in. Here is a brief explanation of the fields :
Package Name – This is the unique name of your package. It must be the same as your Android app, which is usually a reverse of your domain name. As an example, this tutorial uses “com.bricatta.sushiRice”.
Class Name – This is used to automatically launch the app via ‘intent’. This will be used together with the Package Name above to launch the unique app.
Key Hashes – This is the crucial part where must be set properly, or it will not work on Android. This is where most issues and problems arise from. This must be properly created and a special section about this is further below.
Making the App Public
Once these items has been configured, next is to make your facebook app id public, so the whole world can see it. If it isn’t public (default), only the facebook account which created the facebook app, can see the app id (and also other developers which you have added under ‘Roles’. This is not covered in this quick tutorial).
To make the facebook app id public, you will need to ensure that the “App Details” is filled up with your information. Once done, select “Status & Review” and start the submission.
There are 2 way to obtain the key hashes :
- Obtain the key hash from facebook logs
- Generating a key hash using using keytool
First, the easiet and fastest way is to obtain the key hash from the logs. First, ensure the official Facebook mobile application is installed on your android device. Start your Android application and call the facebook API using your mobile application. Run ‘adb logcat’ to view all Android logs. Look for the line :
Here, you will see the ‘key hash’. Just replace any underscore ( “_” ) to slash ( “/” ) and hyphens ( “-” ) to plus sign ( “+” ). In this example, the key hash should be “JGn9F2vDQ/w6hexLxdefCUpxYIA”.
Now, we will explain the second method, which is a long complicated way to generate and create a key hash. You will need ‘keytool’ to proceed. In this tutorial, we will be generating a debug key used during developement. Remember to use your official key later. Goto the directory where your key file is stored (the key that you use to sign your Android application) and run :
or if you are on an Apple Mac :
It will ask for a password. After keying in your password, it will generate a key hash for you. If there is no prompt for a password, something has gone wrong. Most likely the key file isn’t found.
This quick tutorial will be updated if there are any major changes to Facebook’s app id creation. The End.