Error: "Must start TwieetUi Kit in Fabric.with()" but I am



I’m trying to get tweets from a user timeline (e.g. my own “kootsoop”) using the code here and here.

If I put this code into my Activity’s onCreate method:

TwitterAuthConfig authConfig = new TwitterAuthConfig(TwitterHelper.TWITTER_CONSUMER_KEY, TwitterHelper.TWITTER_CONSUMER_SECRET);
Fabric.with(this, new TwitterCore(authConfig), new TweetUi());
UserTimeline userTimeline = new UserTimeline.Builder().screenName("kootsoop").build();

I get an exception at the userTimeline assignment line:

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

But line 2 in my code snippet is calling Fabric.with!

What am I doing wrong or missing? Any pointers appreciated!


It looks like the problem is that there are two places in the app where Fabric.with is called. And mine is the second one. Centralizing the calls to Fabric.with() seems to have fixed my problem.