how to import facebook sdk in android studio?

16,542

make sure you have done the following:

first you have to add the following to the dependencies in your app gradle:

compile 'com.facebook.android:facebook-android-sdk:3.21.1'

In your AndroidManifest.xml you have to include the facebook login activity like so :

    <activity
        android:name="com.facebook.LoginActivity"
        android:label="@string/app_name" />
    <activity

also in the app manifest you have to include your app id as a meta-data tag :

  <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/app_id" /> //Create a string resource with your app id

then you can follow this video which is quiet straight forward :

Facebook Official Android SDK Installation Video

Share:
16,542
robbie demaegdt
Author by

robbie demaegdt

Updated on June 04, 2022

Comments

  • robbie demaegdt
    robbie demaegdt almost 2 years

    I really searched for days to find a good tutorial to import the facebook sdk to make a simpel login system. if the facebook sdk work with the login then I can go on to import contacts and so on. but everytime I try to import it (tryed like 20 different things) it gave me errors. I just need a simple explenation for how I get the facebook sdk in android studio.

  • robbie demaegdt
    robbie demaegdt about 9 years
    thank you, it works for me but in the video they let run the facebook inlog on the oncreate but when I try to put the hole session.openactivesession in a button setonclicklistener is doesn't pop up, when I debug it the request.newMeRequest will not execute. Valid XHTML. that is a image of my onClickListener.
  • J.Vassallo
    J.Vassallo about 9 years
    What are you using the SDK for? Login? Posts? Graph search?
  • robbie demaegdt
    robbie demaegdt about 9 years
    first I try to just login but later in my project I need the permissions to share things, acces to the friendlist, profile photo, public information from people.
  • J.Vassallo
    J.Vassallo about 9 years
    Just not to feel sry about it later first be advised that you can access friends information of only people that installed your app...since the policy change of facebook. Just to make sure you know were you are heading....I will hit office soon and have some code I can share with you about loging in..using graph etc
  • robbie demaegdt
    robbie demaegdt about 9 years
    I just need the friendlist of people so they can challenge each other in sporting. that would be a great help for me, I'm a student so I have a lot to learn about programming android. the video is working for me, just trying now to login on a button click.
  • J.Vassallo
    J.Vassallo about 9 years
    You can do that now only if the user's friends installed your app...you cannot access all friends...very sad indeed
  • robbie demaegdt
    robbie demaegdt about 9 years
    ow that is a disadvantage for programmers that wanna use facebook, I go looking for include other social media and maybe with email invitations
  • J.Vassallo
    J.Vassallo about 9 years
  • robbie demaegdt
    robbie demaegdt about 9 years
    I am back with a question. if I run my program on my cellphone it works, but when I try it on a tablet that it says "app not setup: the developers of this app have not set up this app properly for facebook login" but on the tablet there is a other standard facebook profile (not the one that is programming the app)
  • J.Vassallo
    J.Vassallo about 9 years
    hi!...i posted a new answer for this issue