If you want to integrate your applicaiton with the Facebook, you have to create an Facebook app and enter information.
After you have completed creating your new Facebook application, you should note your applcationID , because you will use it in your applicaiton to connect Facebook.
Download and install Facebook sdk
- Goto github and download facebook sdk
- After Downloading Facebook SDK open your android project and copy files from facebook folder to you application. ~\facebook-android-sdk-master\facebook-android-sdk-master\facebook\src\com\facebook\android
- After copying Facebook files you can develop your applicaiton to connect facebook.
Let's try to run our application, what will happen ?
It gives an error, because you didnt fill the keyhash and Package name and classname fields in your Facebook application administration panel.
Filling Packagename and classname is easy, it comes from your manifest, you can refer to below url.
And now there are one empty fied named keyhas. Lets create our keyhas. There are an important point which should be paid attention. When you publish our application to google play, we will use our release.keystore so while creating our keyhash we will use this key.
(To learn how to create keystore you can refer this url)
To create keyhash,
- Download openSSl from Code Extract it. create a folder- OpenSSL in C:/ and copy the extracted code here.
- detect debug.keystore file path. If u didn't find, then do a search in C:/ and use the Path in the command in next step.
- If we publish it we have to use release.keysore
- C:\Program Files (x86)\Java\jre6\bin\keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64 (this is for debug)
- C:\Program Files (x86)\Java\jre6\bin\keytool -exportcert -alias typeyourkeystorealias -keystore C:\path\release.keystore | C:\OpenSSL\bin\openssl sha1 -binary| C:\OpenSSL\bin\openssl base64 (this is for release)
- Now we can create our keyhash. (I used debug.keystore and execute it in java\bin you can do the same if you want)
Our keyhash is ready now, copy and past it to keyhash filed in facebook apps page. (Dont try to write it , just right click to your cmd screen and click mark, then select that area where key is written, then pres enter.)
if you have got the same error, please generate your keyhash with release.keystore.
I hope it helps you to connect facebook from your android app.