Android Integrate Facebook Login Tutorial

Most of the time login with password maybe not convenience  to the user in the mobile application. Therefore, facebook provide a SDK that allow the android application login with just using their facebook account. It no require register an account in the mobile application, mobile user just need to click the facebook login button to use the application. By using facebook SDK, developer allow to get user profile information from the facebook database. Therefore, it is a very nice feature for both developer and user. In this tutorial, I will give you the steps on how to use facebook SDK to perform one click login by using facebook account.

Register a Facebook Developer Account

Enter this link in your browser and register your facebook account to developer account.

Create a New App ID

In the right corner click your profile and select “Add a New App”.fblogin1-a


Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “FacebookLoginExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Edit build.gradle (module:app)

Go to your build.gradle (module:app) file and add maven central responsitory before dependencies.

After that add dependencies for compiling the facebook sdk provided by facebook.

Then click build button to build the latest changes on build.gradle.

Edit strings.xml file

You can check your app id from your app name dashboard or click this link to check your app id

Edit Android.Manifest.xml

Add the internet permission in the android.manifest file so your app able to use internet access.

After that add facebook meta data element in the application element.

Generate Key Hashes

Go to your and insert the following source code.

Put this method in your onCreate() and run your project to get your key hashes in the logcat.

App DashBoard Settings

Go to dashboard of your app and select basic settings. Enter your Google Play Package Name, Class Name and Key Hashes that just generate.



Make your App Public

In your App Dashboard, click app review in the left navigate section and click the toggle to change your app to public.


Edit activity.main.xml layout

Go to activity.main.xml and add the facebook login button that provide by the facebook sdk. You can follow the source code below.

Edit class

Navigate to this class and copy the source code below and paste it in your class. It is to perform the login feature.

Run your project

Now, you are able to use facebook login in your android project. Try it now in your android device.


This link is all the permissions that you able take by user. It able to take many kind of information from the user that given by facebook.

(Android Integrate Facebook Login)

Source Code

(Visited 402 times, 1 visits today)

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

2 Responses

  1. hahn says:

    how to detect facebook account from this app? everytime i click login button, i must insert email and password (even i have login in official facebook app and android browser)

    sorry for my english

    • Kristofer Ng says:

      i think u should add this in your Manifest file.

      < activity

Leave a Reply

Your email address will not be published. Required fields are marked *