Steps to Integrate Latest Facebook SDK with your Android Application

If you want to link Facebook with your Android Application to carry out Login or integrate the Share or Like Facebook button, you need to make use of the Facebook SDK for Android,

What you can do using Facebook SDK Integration?

  • Facebook Login: You can let your app users log in using the Facebook Login credential (3rd Party oAuth login)
  • Facebook Share: Users off your app can share content to Facebook, for example, Game score, Image, Event, Share Dialogs, Text, etc.
  • Graph API: Get access to the Facebook Graph API, that gives you access to read and write to the Facebook social graph. You can get data in and out of Facebook's social graph, you can query the data, post stories on Facebook, you can even upload photos, as well as perform other tasks.
  • App Events: You can log events in your application.
  • Facebook Analytics: Let's more insights into how people are using your application.
  • App Links: This is an open standard that you can use to deep-link to the content in your application.

Components of Facebook SDK

There are 6 components in the Facebook SDK,

  1. Core SDK - This includes Analytics
  2. Login SDK
  3. Sharing SDK
  4. Places SDK
  5. Messenger SDK
  6. App Links SDK

Steps to Integrate the Facebook Android SDK in Android Studio:

⛏️ Make sure if you are trying to integrate the Latest Facebook SDK Version 7.1.0, you need to be on minimum version Android API version 15, i.e. Android 4.0.3 -Ice Cream Sandwich.

  1. Open IntelliJ's Android Studio, File -> New -> New Project...,
  2. Select any Phone or Tablet Activity template and click Next,
  3. Now under Configure your Project, make sure you select Minimum SDK as API 15 or higher, Click Finish
  4. Now under your project folder/directory go to Gradle Scripts and open the build.gradle file which as the name (Project: Your Project Name) next to it,
  5. Now add mavenCentral() under repositories and save the file, your file will look something like this,
  6. // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
        dependencies {
            classpath ""
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
    allprojects {
        repositories {
    task clean(type: Delete) {
        delete rootProject.buildDir
  7. Now open the other build.gradle file that has prefix (Module: app),
  8. Add like implementation '[5,6)' in the dependencies section, save the file, it should look like below,
  9. apply plugin: ''
    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.3"
        defaultConfig {
            applicationId "com.code2care.myapplication"
            minSdkVersion 23
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), ''
    dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.2'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
        implementation '[5,6)'
  10. Now go to, app -> res -> values -> strings.xml file and add: <string name="facebook_app_id">Facebook App ID</string>
  11. Go to app -> manifests -> AndroidManifest.xml and add user permission for Internet: <uses-permission android:name="android.permission.INTERNET"/>,
  12. Add the below under application, your manifest file will look like below,
  13. <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android=""
        <uses-permission android:name="android.permission.INTERNET"/>
            <activity android:name=".MainActivity">
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
            <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
  14. Facebook SDK has been integrated in your application, you can try running the HelloFacebookSample code that come with the SDK.
Integrate Facebook SDK with Android Project
Integrate Facebook SDK with Android Project
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap