Upgrading

Upgrade to Twitter Kit 3.0

Note

With Twitter Kit 3.0, changes have been made to how Twitter API keys are managed. Please refer to Upgrading from Fabric for details.

Twitter Kit no longer has a dependency on Fabric. In order to continue using functionality provided by Fabric you should directly include Fabric as a dependency.

Twitter Kit 3.0 includes a number changes that must be taken into consideration when upgrading from 2.x. The sections below outlines these changes.

Binary Distribution

Twitter Kit binaries are no longer distributed through Fabric’s maven repository. All binaries are now distributed through Bintray jcenter. Most Android projects should already include jcenter so no changes are required.

Twitter Kit Initialization

Calling Fabric.with(Fabric) is no longer required. Twitter Kit is now initialized by calling Twitter.initialize(TwitterConfig)

Individual kits are now initialized the first time getInstance() method is called on each component. If getInstance() is called before calling Twitter#initialize() an IllegalStateException will be thrown. For more details see Twitter Installation

Request email permission screen removed

The permission screen shown when calling TwitterAuthClient#requestEmail() has been removed. We no longer require 3rd party apps to display the permission screen to request the user’s email. The requestEmail() method will now return the user’s email address without displaying the permission screen.

App card creation removed from composer

Twitter Kit no longer supports programmatic creation of App Cards through the native composer. The native composer will remain and will be expanded to include additional features in the coming months. For more details see Compose Tweets

  • [Removed] The Card class and ComposerActivity.Builder#card method was removed.
  • [Added] The ComposerActivity.Builder#image method was added for attaching an image to the Tweet.
  • [Added] The ComposerActivity.Builder#text method was added for setting default composer text.

Miscellaneous

  • [Changed] Tweet#extendedEtities was changed to Tweet#extendedEntities
  • [Removed] TwitterCore#logIn(Activity, Callback) was removed use TwitterLoginButton or TwitterAuthClient instead.
  • [Removed] TwitterCore#logOut() was removed use TwitterCore.getInstance().getSessionManager().clearActiveSession() instead.

Some classes in io.fabric.sdk.android.* have been moved to com.twitter.sdk.android.core.*. These include:

  • Logger
  • DefaultLogger
  • ExecutorUtils
  • CommonUtils

Upgrade to Twitter Kit 2.0

Note

It is important to note that Twitter Kit 2.0 supports Android 14+. Please do not upgrade to Twitter Kit 2.0 if your project needs to be built for Android versions less than 14.

Digits Kit is no longer a dependency of Twitter Kit. Digits Kit should be included separately. See Digits Installation Guide.

Twitter Kit 2.0 includes a number of new and deprecated methods that must be taken into consideration when upgrading from 1.x. The sections below outlines these changes.

Migrate from Retrofit 1.x to Retrofit 2.x

  • [Changed] Retrofit 2 service interface provides the ability to perform synchronous and asynchronous requests using a single pattern. All service interfaces in Twitter Kit have been updated to return the Call<t> object.
// Synchronous call in Retrofit 2.0
Call<Tweet> call = statusService.show(20L, null, null, null);
Tweet tweet = call.execute();

// Asynchronous call in Retrofit 2.0
Call<Tweet> call = statusService.show(20L, null, null, null);
call.enqueue(new Callback<Tweet>() {
  @Override
  public void success(Result<Tweet> result) {
    //Do something with result
  }

  public void failure(TwitterException exception) {
    //Do something on failure
  }
});

// Cancel asynchronous call in Retrofit 2.0
Call<Tweet> call = statusService.show(20L, null, null, null);
call.cancel();
  • [Changed] OkHttp 3.2+ is now a required dependency of Retrofit 2.0. OkHttp provides a reliable HTTP stack, a faster retry mechanism, and HTTP2/SPDY support. There is no need to include OkHttp in gradle dependencies.

Removal of deprecated methods or classes

  • [Removed] The TweetViewAdapter class was removed. Replace with TweetTimelineListAdapter and a FixedTweetTimeline with a set of Tweets.
  • [Removed] The TweetViewFetchAdapter class was removed. Load Tweets by id with TweetUtils#loadTweets and use a TweetTimelineListAdapter with a FixedTweetTimeline.
  • [Removed] The TweetUtils#loadTweet(final long tweetId, final LoadCallback<Tweet> loadCallback) method was removed. Use TweetUtils#loadTweet(final long tweetId, final Callback<Tweet> callback) instead.
  • [Removed] The TweetUtils#loadTweets(final List<Long> tweetIds, LoadCallback<List<Tweet>> loadCallback) method was removed. Use TweetUtils#loadTweets(final List<Long> tweetIds, Callback<List<Tweet>> callback) instead.
  • [Removed] The TwitterAuthConfig#signRequest(...) method was removed. Use OAuthSigning#getAuthorizationHeader(...) instead.

Remove application-only authentication

Application-only authentication has lower rate limits and access restrictions that make it inappropriate for large mobile applications.

  • [Removed] The AppSession class was removed. No replacement has been provided.

Removal of guest authentication methods on TwitterCore instance

  • [Removed] The TwitterCore#logInGuest method was removed. Guest authentication refresh logic is now automatically handled by Twitter Kit.