从结构中删除后,如何将twitter集成到android中以进行twitter登录? [英] how to integrate twitter in android for twitter login after it's removal from fabric?

查看:193
本文介绍了从结构中删除后,如何将twitter集成到android中以进行twitter登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试集成Twitter登录. Twitter的登录按钮显示为灰色. 我读过某个地方,在设置内容视图以使其起作用之前,我必须添加以下行:

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);

但是android studio无法识别'Fabric'.它具有红色.这是代码:

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

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

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

此外,"Twitter"下方还有一个红色下划线,并且出现以下错误:

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

'Twitter(com.twitter.sdk.android.core.TwitterConfig)'具有私有 在"com.twitter.sdk.android.core.Twitter"中访问

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

此外,我已经尝试了android studio的Fabric插件,但是没有用于Twitter登录的选项:

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

推荐答案

代替

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

这样写:

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

此外,您需要在gradle(应用程序级别)中添加此行:

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

编译'com.twitter.sdk.android:twitter:3.0.0'

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

这篇关于从结构中删除后,如何将twitter集成到android中以进行twitter登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆