Android Studio 0.8.1 – how to use Facebook SDK?

Using Facebook SDK 3.23 in Android Studio 1.1 preview 2

Two choices :

*Maven Repository for the Facebook SDK.

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}

check for the latest version facebook sdk

OR

*Follow the steps below:

1.Download facebook sdk
https://developers.facebook.com/docs/android/

2.Unzip the archive facebook-android-sdk-3.23.0

3.File menu->Import Module

4.Chose “facebook” folder inside the unzipped archive.

5.Go to directory facebook/build.gradle change this part

This:

 compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    }

To proper sdk version

example:

 compileSdkVersion 21
        buildToolsVersion '21.1.1'

        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 21
        }

6.Click your project and press F4 ,go to ‘dependencies’ tab, click ‘+’, ‘module dependency’ and select your imported facebook module.

7.Resync and rebuild

Leave a Comment