0

Hey so I am building an app and trying to incorporate twitter feeds into the app, and I am using Fabric to do it. I have installed correctly and everything is building fine, but when I attempt to run the following, which is from the example at https://docs.fabric.io/android/twitter/show-timelines.html

I get the following exception:

java.lang.IllegalStateException: Must start TweetUi Kit in Fabric.with().

Any ideas??

package com.android.twitterApp;

import io.fabric.sdk.android.Fabric;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;

import com.android.twitterApp.R;
import com.digits.sdk.android.Digits;
import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.twitter.sdk.android.core.TwitterCore;
import com.twitter.sdk.android.tweetui.TweetTimelineListAdapter;
import com.twitter.sdk.android.tweetui.UserTimeline;



public class TwitterAPIActivity extends ListActivity {

// Note: Your consumer key and secret should be obfuscated in your source code before shipping.

private static final String TWITTER_KEY = "**********";
private static final String TWITTER_SECRET = "*********";

private Intent intent;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new TwitterCore(authConfig), new Digits());

    setContentView(R.layout.timeline);

    final UserTimeline userTimeline = new UserTimeline.Builder()
        .screenName("fabric")
        .build();

    final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
        .setTimeline(userTimeline)
        .build();

    setListAdapter(adapter);
}

}

fulhamHead
  • 687
  • 1
  • 10
  • 23

1 Answers1

2

The Fabric SDK separates functionality into modules called Kits. You must indicate which kits you wish to use via Fabric.with(). This is typically done by extending Android’s Application class.

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        TwitterAuthConfig authConfig = 
                   new TwitterAuthConfig("consumerKey",
                                         "consumerSecret");

        Fabric.with(this, new Twitter(authConfig));

        // Example: multiple kits
        // Fabric.with(this, new Twitter(authConfig),
        //                  new Crashlytics());
    }
}

More info: https://dev.twitter.com/twitter-kit/android/integrate

See the canonical sample app at: https://github.com/twitterdev/cannonball-android

acostela
  • 2,597
  • 3
  • 33
  • 50
Abhilash Das
  • 1,388
  • 1
  • 16
  • 22