Skip to content
This repository has been archived by the owner. It is now read-only.

Getting Started

Eric Frohnhoefer edited this page Dec 7, 2017 · 5 revisions

The Android SDK is a collection of individual libraries designed to make interacting with Twitter seamless and efficient. This includes:

  • TwitterCore for Twitter login and API access.
  • TweetUi for displaying Tweets and Timelines.
  • TweetComposer for creating Tweets.
  • Twitter + MoPub for monetizing Twitter timelines with MoPub.

Twitter requires that all API requests be authenticated with tokens that can be traced back to an individual Twitter App. To create a new Twitter app or use existing Twitter app, visit Twitter app dashboard and copy the keys from the “Keys and Access Tokens” tab of your app page. You will need your consumer key and secret to complete the process.

Add Twitter Kit Dependencies

To get started you will need to add the following dependencies to your application's Gradle config (usually app/build.gradle).

dependencies {
  // Include all the Twitter APIs
  compile ''
  // (Optional) Monetize using mopub
  compile ''

In some cases it may be desirable to include only the necessary dependencies to avoid the Android dex limit.

dependencies {
  compile ''
  compile ''
  compile ''
  compile ''

All the Twitter Kit artifacts are distributed through Bintray jcenter. Make sure jcenter is included in your repositories scope.

repositories {

Initialize Twitter Kit

Once you’ve included the Twitter Kit dependencies you must initialize Twitter Kit. If using a custom Application class you can initialize Twitter Kit in the onCreate() method.

public class CustomApplication {
  public void onCreate() {

Next, add your API key and secret to your application resources.

  <string android:name="">XXXXXXXXXXX</string>
  <string android:name="">XXXXXXXXXXX</string>

Optionally, you can change the default configuration by calling initialize with custom configuration.

public void onCreate() {
  TwitterConfig config = new TwitterConfig.Builder(this)
    .logger(new DefaultLogger(Log.DEBUG))
    .twitterAuthConfig(new TwitterAuthConfig("CONSUMER_KEY", "CONSUMER_SECRET"))
Builder Method Description
logger(Logger) Global logger to be used. Default log level is Log.INFO.
twitterAuthConfig(TwitterAuthConfig) Programmatically set consumer key and secret. By default value is read from Android Resources.
debug() Enable debug mode.

Once Twitter kit has been initialized TwitterCore, TweetUi, and TweetComposer can be accessed through their singleton accessor.

  • TwitterCore.getInstance()
  • TweetUi.getInstance()
  • TweetComposer.getInstance()

Next Steps

Once you’ve installed Twitter, the following sections contain more detailed documentation for each feature.

You can’t perform that action at this time.