Jacob Collins Jacob Collins - 2 years ago 284
Android Question

Twitter Fabric Login for Android

I'm attempting to use the new Fabric API that Twitter is offering to let users login to my app. I've followed the tutorial exactly (at least I think I have, maybe I've made some mistakes) here after setting up my project with all of the necessary steps; now when I hit the login button and authenticate the button gives back a successful response but when I go to get the Twitter Session after that I get an exception that looks like

Caused by: java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first

(again, I followed the tutorial to a T up to this point, but if you can think of anything then I'd be willing to try it)

Answer Source

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.

package com.example.app;
import android.app.Application;

public class MyApplication extends Application {
    public void onCreate() {

        TwitterAuthConfig authConfig = 
                   new TwitterAuthConfig("consumerKey",

        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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download