我只是将TwitterLoginButton添加到我的LoginActivity中,并且应用程序停止,但出现以下异常:
膨胀类com.twitter.sdk.android.core.identity.TwitterLoginButton的错误
查看我的xml片段
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_welcome"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<!--<com.twitter.sdk.android.core.identity.TwitterLoginButton-->
<!--android:id="@+id/button_twitter_login"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" />-->
.......
</android.support.constraint.ConstraintLayout>
</ScrollView>
此外,有没有没有TwitterLoginButton的Twitter登录方法? 我找到了这个解决方案,但是对我来说不起作用,因为我无法导入TwitterAuthClient
Twitter login without TwitterLoginButton
另外,请参阅我的gradle依赖项
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.mikhaellopez:circularimageview:3.0.2'
implementation 'me.zhanghai.android.materialratingbar:library:1.3.1'
implementation 'com.iarcuschin:simpleratingbar:0.1.5'
//authentication
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.facebook.android:facebook-login:4.35.0'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:2)
根据docs,您需要在应用程序类onCreate中使用结构初始化Twitter身份验证:
@Override
public void onCreate() {
super.onCreate();
TwitterAuthConfig authConfig = new TwitterAuthConfig("consumerKey", "consumerSecret");
Fabric.with(this, new TwitterCore(authConfig));
}