Search code examples
androidfacebookandroid-studiofacebook-sdk-4.0

include facebook sdk in android studio


I'm followed some tuts for including the FB SDK but when I want to import

import com.facebook.FacebookSdk;

I need this for FB analytics, so I'm created the class fbanalytic :

image here

and we see it's hidden i dont know fix it

and also someone his tell that class it's not important specialy in the latest version in fb sdk ,is that correct? currently im using latest verion :facebook-android-sdk-4.22.1


Solution

  • Using the Facebook SDK:

    1. Import the sdk by adding compile dependency to build.gradle file

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

    2. Now when you are trying to use something from Facebook's SDK it should be AUTOMATICALLY imported to your files.

    In your example you are making a new Class that does uses AppEventsLogger that is part of Facebook SDK. The import statement that you presumably wrote (import com.facebook.FacebookSDK) is grey and second import statement clearly shows that it is importing form com.facebook.* SDK.

    tldr: Android Studio imports from Facebook SDK as expected.