简体   繁体   English

在android中使用firebase登录facebook时出现InflateException

[英]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.

相关问题 Facebook登录android.View.InflateException错误 - Facebook Login android.View.InflateException error Android应用程序-使用Facebook登录与Firebase身份验证 - Android app - using facebook login with firebase auth Facebook使用Firebase BaaS登录Android - Facebook login with Android using Firebase BaaS Firebase Facebook 登录 android - Firebase Facebook login android 在Android中使用Facebook登录时未调用onActivityResult - onActivityResult is not calling while using facebook login in android 如何在Android Studio中使用带有片段和Viewpager的Facebook登录进行Firebase身份验证? - How to Firebase Authenticate Using Facebook Login in Android Studio with fragments and viewpager? 使用Facebook Android登录 - Login using facebook android 在Android中使用Facebook登录 - using facebook login in android 确认登录后显示退出按钮,并在使用Facebook Login Integration Android登录时进入活动状态 - Shows Logout Button after confirm login and goes to activity while login using Facebook Login Integration Android Android Firebase:无需使用Google,facebook等登录提供程序即可检索单个用户数据和自定义登录 - Android Firebase:To retrieve single user data and custom login without using login providers like google,facebook etc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM