dependencies {}
section of your build.gradle (module: app)
file to compile the latest version of the Facebook SDK :implementation 'com.facebook.android:facebook-android-sdk:latest.release'
No special steps are required to upgrade to 4.41.0.
No special steps are required to upgrade to 4.40.0.
No special steps are required to upgrade to 4.39.0.
No special steps are required to upgrade to 4.38.1.
No special steps are required to upgrade to 4.38.0.
No special steps are required to upgrade to 4.37.0.
No special steps are required to upgrade to 4.37.0.
No special steps are required to upgrade to 4.36.1.
No special steps are required to upgrade to 4.36.0.
No special steps are required to upgrade to 4.35.0.
No special steps are required to upgrade to 4.34.0.
No special steps are required to upgrade to 4.33.0.
No special steps are required to upgrade to 4.32.0.
No special steps are required to upgrade to 4.31.0.
Account Kit preferences API is deprecated. After upgrading to graph api v1.3 you will not longer be able to store key-value pairs on user preferences.
No special steps are required to upgrade to 4.29.0.
No special steps are required to upgrade to 4.28.0.
GraphRequest.createOpenGraphObject(ShareOpenGraphObject)
to ShareGraphRequest.createOpenGraphObject(ShareOpenGraphObject)
instead.FacebookSDK.[set|get]WebDialogTheme(...)
to WebDialog.[set|get]WebDialogTheme(...)
. No special steps are required to upgrade to 4.27.0.
No special steps are required to upgrade to 4.26.0.
No special steps are required to upgrade to 4.25.0.
No special steps are required to upgrade to 4.24.0.
No special steps are required to upgrade to 4.23.0.
No special steps are required to upgrade to 4.22.1.
The title
, description
, caption
and image
field of FBSDKShareLinkContent
have been deprecated. Please take appropriate action to remove usage of them.
Remove the loginType
parameter from constructor of SkinManager
when assigning a new UI Manager.
When using SkinManager
, you no longer need to specify the AppLoginTheme
for AccountKitActivity
in AndroidManifext.xml
.
No special steps are required to upgrade to 4.21.1.
No special steps are required to upgrade to 4.21.0.
No special steps are required to upgrade to 4.20.0.
The Facebook SDK is now auto initialized on Application start. If you are using the Facebook SDK in the main process and don't need a callback on SDK initialization completion you can now remove calls to FacebookSDK.sdkInitialize. If you do need a callback, you should manually invoke the callback in your code.
Basic App Events are now logged after initializing the Facebook SDK. Calls to activateApp can now be removed from your application. This feature can be disabled by following the instructions in App Events docs.
The LoginButton UI is changed in 4.19.0. Instead of "Log in with Facebook", the button now displays "Continue with Facebook". The button color is changed to #4267B2 from #3B5998. The button height is decreased from 30dp to 28dp due to use of smaller font size and paddings around a larger Facebook logo.
The interface for using LoginButton remains the same. Please take time to ensure the updated LoginButton does not break your app's UX
The Account Kit SDK is now auto initialized on Application start. If you are using the Account Kit SDK in the main process and don't need a callback on SDK initialization completion you can now remove calls to AccountKit.initialize. If you do need a callback, you should manually invoke the callback in your code.
No special steps are required to upgrade to 4.19.0.
No special steps are required to upgrade to 4.18.0.
If you use Account Kit Advanced UI, make sure to handle the three new screens as noted in the docs.
No special steps are required to upgrade to 4.16.1.
No special steps are required to upgrade to 4.16.0.
Classes and methods associated with App and Game Groups have been deprecated. Please take appropriate action to remove usage of them.
No special steps are required to upgrade to 4.14.1.
No special steps are required to upgrade to 4.14.0.
No special steps are required to upgrade to 4.13.2.
No special steps are required to upgrade to 4.13.1.
No special steps are required to upgrade to 4.13.0.
No special steps are required to upgrade to 4.12.1.
No special steps are required to upgrade to 4.12.0.
Instead of calling AppEventsLogger.activateApp
and AppEventsLogger.deactivateApp
in each Activity, you should now just call AppEventsLogger.activateApp(Application)
from your Application's onCreate method and the SDK will automatically track sessions for you.
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); } }
Note the v4.11 SDK targets v2.6 of the Graph API.
No special steps are required to upgrade to 4.10.1.
If you relied on graph requests being localized. You now have to specify the locale parameter manually.
No special steps are required to upgrade to 4.9.0.
No special steps are required to upgrade to 4.8.2.
No special steps are required to upgrade to 4.8.1.
No special steps are required to upgrade to 4.8.0.
The SDK now targets v2.5 of the Graph API. Please review the Graph API changelog for details.
The GameRequestContent 'to' member has been deprecated and replaced with Recipients.
The SDK now requires a minimum sdk of API level 15 or above.
No special steps are required to upgrade to 4.5.1.
No special steps are required to upgrade to 4.5.0.
No special steps are required to upgrade to 4.4.1.
The SDK now targets v2.4 of the Graph API. Please review the Graph API changelog for details. For example, the number of default fiends returned by Graph endpoints have been reduced and you should always explicitly ask for the fields you need.
No special steps are required to upgrade to 4.3.0.
The method to set the custom request code for the login button has been removed.
No special steps are required to upgrade to 4.1.2.
No special steps are required to upgrade to 4.1.1.
There is one breaking change from 4.0.
Style attr tags are now namespaced to avoid conflicts. Apps will need to add the namespace "com_facebook_
" to their existing facebook sdk style attrs.
For example.
facebook:preset_size="small"
becomes
facebook:com_facebook_preset_size="small"
No special steps are required to upgrade to 4.0.1.
The Facebook SDK for Android v4.0 is a major version upgrade which features:
For full instructions on install and setup for 4.x, see Getting Started Android SDK.
Set up the app ID in AndroidManifest.xml
as in 3.x
If you use any native dialogs such as Share or Invite add your app name to AndroidManifest.xml
:
<meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/app_name"
LoginActivity
is replaced by FacebookActivity
. Add this in AndroidManifest.xml
:<activity android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
FacebookSdk.sdkInitialize
from onCreate
in Activity
or Application
:@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(this.getApplicationContext()); }
FacebookSdk
class for other configurations you can set at app launch.For more information on Login in 4.x, also see Facebook Login for Android.
Session Removed - AccessToken
, LoginManager
and CallbackManager
classes supercede and replace functionality in the Session
class.
Access Tokens - You can load AccessToken.getCurrentAccessToken
with the SDK from cache or if the app is cold launched from an app bookmark. For instructions, see Facebook Login for Android, Get Current Token.
Login Button - The easiest way to add Login is to use the LoginButton
in 4.x. See Facebook Login for Android, Add Facebook Login.
UserSettingsFragment
class has been removed from the SDK.
LoginManager
is a singleton instance, and works with the AccessToken
's currentAccessToken
. After login the SDK sets currentAccessToken
. To get additional permissions call the logInWith...
methods.
LogInWith...
methods always open a prompt UI if necessary. There's no equivalent to the Session.openActiveSessionFromCache
or Session.OpenActiveSession(Activity, boolean, StatusCallback)
. Instead, you should check AccessToken.getCurrentAccessToken()
at onCreate(), and if not null, skip login.
AccessToken
broadcast events when it is set, unset or updated. Use the AccessTokenTracker
to receive these events. See Facebook Login for Android, Track Access Tokens.currentAccessToken
automatically caches when the SDK sets it.ProfileTracker.getCurrentProfile
returns the current logged in user.ProfileTracker
returns events if the logged in user changes. see Facebook Login for Android, Track Current Profile.CallbackManager.onActivityResult
replaces Session.onActivityResult
and UiLifecycleHelper.onActivityResult
. See Facebook Login for Android, Register a Callback.For more information on Android and Graph API in 4.x, also see Using the Graph API, Android.
Request
and Response
classes in v3 are now called GraphRequest
and GraphResponse
.Session
in v3 now take AccessToken
or implicitly use AccessToken.getCurrentAccessToken
if you don't provide one.newMeRequest
, newMyFriendsRequest
returned a typed parameter in the callback like GraphUser
or List<GraphUser>
now pass in generic JSONObject
and JSONArray
instead.The old version:
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (user != null) { profilePictureView.setProfileId(user.getId()); } } }).executeAsync();
The new version
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject user, GraphResponse response) { if (user != null) { profilePictureView.setProfileId(user.optString("id")); } } }).executeAsync();
FacebookRequestError
class has more error handling information. See Using the Graph API, Android.LoggingBehavior.GRAPH_API_DEBUG_WARNING
or LoggingBehavior.GRAPH_API_DEBUG_INFO
flags in the FacebookSdk
class.For more information on Android and Sharing in 4.x, also see Sharing on Android.
Content
object which represents the data for that dialog. For example AppInvitesDialog
shows the AppInvitesContent
. Each Content
class also has a corresponding Builder
to help you build the content object. These are in the com.facebook.share.model
package. See Sharing on Android, Modeling Content.Dialog
classes for every type of dialog that Facebook offers. They are in the com.facebook.share.widget
package. See Sharing on Android, Add Sharing UIs.WebDialog.FeedDialogBuilder
in v3.x), you should now use ShareDialog
, which will use the native Share Dialog in the Facebook app if installed, and fall back to a webview. If you explicitly want to show only the Feed Dialog, you can use ShareDialog.show(content, ShareDialog.Mode.FEED)
;SendButton
and ShareButton
which are drop-in replacement buttons for the MessageDialog
and ShareDialog
respectively.No major API changes, but classes are now in com.facebook.appevents
.