Facebook Audience Network

random

How to import facebook sdk in android studio

The Facebook SDK for Android is the easiest way to integrate your Android app with Facebook. It enables:

Maven (Preferred Download Method)

Add this to Module-level /app/build.gradle before dependencies:

If you do not know the use of the code then watch the video

  
repositories {
// You can also use jcenter if you prefer
mavenCentral
()
}
Add the compile dependency with the latest version of the Facebook SDK in the build.gradle file:

Step 1

Copy the code to the quote you work on Android Studio
dependencies { 
// Facebook SDK Core only (Analytics)
compile
'com.facebook.android:facebook-core:4.+'
// Facebook Login only
compile
'com.facebook.android:facebook-login:4.+'
// Facebook Share only
compile
'com.facebook.android:facebook-share:4.+'
// Facebook Places only
compile
'com.facebook.android:facebook-places:4.+'
// Facbeook Messenger only
compile
'com.facebook.android:facebook-messenger:4.+'
// Facebook App Links only
compile
'com.facebook.android:facebook-applinks:4.+'
// Facebook Android SDK (everything)
compile
'com.facebook.android:facebook-android-sdk:4.+'
// Audience Network SDK. Only versions 4.6.0 and above are available
compile
'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
compile
'com.facebook.android:account-kit-sdk:4.+'
}

dependencies { 
// Facebook SDK Core only (Analytics)
implementation 'com.facebook.android:facebook-core:4.+'
// Facebook Login only
implementation 'com.facebook.android:facebook-login:4.+'
// Facebook Share only
implementation 'com.facebook.android:facebook-share:4.+'
// Facebook Places only
implementation 'com.facebook.android:facebook-places:4.+'
// Facbeook Messenger only
implementation 'com.facebook.android:facebook-messenger:4.+'
// Facebook App Links only
implementation 'com.facebook.android:facebook-applinks:4.+'
// Facebook Android SDK (everything)
implementation 'com.facebook.android:facebook-android-sdk:4.+'
// Audience Network SDK. Only versions 4.6.0 and above are available
implementation 'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
implementation 'com.facebook.android:account-kit-sdk:4.+'
}

Android Studio Setup
To use the Facebook SDK in a project, add the SDK as a build dependency and import the SDK.
  1. Go to Android Studio | New Project | Minimum SDK.
  2. Select API 15: Android 4.0.3 (IceCreamSandwich) or higher and create your new project.
  3. After you create a new project, open Gradle Scripts | build.gradle (Project: <your_project> and do the following:
    1. implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    2. Save and close build.gradle (Module: app).
  4. Build your project. Now you can import com.facebook.FacebookSdk into your app.

Add Facebook App ID

Then add your Facebook App ID to your project's strings file and update your Android manifest:
1. Open your /app/res/values/strings.xml file.
2. Add a string element with the name attribute facebook_app_id and value as your Facebook App ID to the file. For example
<string name="facebook_app_id">Facebook App ID</string>
3. Open /app/manifests/AndroidManifest.xml
4. Add a uses-permission element to the manifest:
<uses-permission android:name="android.permission.INTERNET"/>
5. Add a meta-data element to the application element:
<application android:label="@string/app_name" ...>
...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
...
</application>

Sending Images or Videos

If you're sharing links, images or video via the Facebook for Android app, you also need to declare the FacebookContentProvider in the manifest.
Append your app id to the end of the authorities value. For example if your Facebook app id is 1234, the declaration looks like:
<provider android:authorities="com.facebook.app.FacebookContentProvider1234"
android:name="com.facebook.FacebookContentProvider"

android:exported="true" />

How to import facebook sdk in android studio Reviewed by Code Labe on April 20, 2019 Rating: 5

Contact Form

Name

Email *

Message *

Powered by Blogger.