[英]InflateException while login with facebook using firebase in android
I want to login facebook with firebase in my android app, so after connecting my app with firebase I have added the dependency of facebook sdk compile 'com.facebook.android:facebook-android-sdk:[4,5)'
but when I run my app then it shows 我想在我的Android应用程序中使用compile 'com.facebook.android:facebook-android-sdk:[4,5)'
登录facebook,所以在将我的应用程序与firebase连接后,我添加了facebook sdk compile 'com.facebook.android:facebook-android-sdk:[4,5)'
的依赖关系,但是当我运行我的应用程序然后它显示
android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.facebook.login.widget.LoginButton android.view.InflateException:二进制XML文件行#20:二进制XML文件行#20:错误输出类com.facebook.login.widget.LoginButton
XML Code XML代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.environer.becofriend.MainActivity"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.facebook.login.widget.LoginButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Note: I have not added any code in my MainActivity because the sdk is initialized automatically in new sdk 注意:我没有在MainActivity中添加任何代码,因为sdk在新的sdk中自动初始化
Try this, I think changing the grade will do the work, I Have working example 试试这个,我认为改变成绩会做的工作,我有工作的例子
1) Gradle 1) Gradle
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
2) XML 2) XML
<com.facebook.login.widget.LoginButton
android:background="@drawable/login_button_back_one"
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
3) Java 3) Java
private AccessTokenTracker accessTokenTracker;
private ProfileTracker profileTracker;
private CallbackManager callbackManager;
LoginButton loginButton;
FacebookSdk.sdkInitialize(ActivityName.this);
loginButton = (LoginButton) findViewById(R.id.login_button);
callbackManager = CallbackManager.Factory.create();
accessTokenTracker= new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) {
}
};
accessTokenTracker.startTracking();
private void displayMessage(Profile profile){
if(profile != null){
Log.v("@@@WWE"," "+profile);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.