Search code examples
androidandroid-studiotwittertwitter-fabrictwitter-login

how to integrate twitter in android for twitter login after it's removal from fabric?


I am trying to integrate twitter login. The login button of twitter is grayed out. I have read somewhere that i have to add these line before setting content view to make it work:

TwitterAuthConfig authConfig =  new TwitterAuthConfig(
                getString(R.string.twitter_consumer_key),
                getString(R.string.twitter_consumer_secret));

        Fabric.with(this, new Twitter(authConfig));//here,i am having problem

        setContentView(R.layout.activity_cover);

But android studio does not recognize 'Fabric' .It has red color.This is the code:

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

Also, there is a red underline below 'Twitter',and i have the following error:

'Twitter(com.twitter.sdk.android.core.TwitterConfig)' has private access in 'com.twitter.sdk.android.core.Twitter'

Also,i have tried fabric plugin of android studio,but there is no option for twitter login:

fabric plugin


Solution

  • Instead of

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

    write this:

            TwitterConfig.Builder builder=new TwitterConfig.Builder(this);
            builder.twitterAuthConfig(authConfig);
            Twitter.initialize(builder.build());
    

    Also,you need to add this line in gradle(app level) :

    compile 'com.twitter.sdk.android:twitter:3.0.0'