我正在使用Firebase UI登录到我的应用程序,但是当我使用Facebook Builder时,它停止了该应用程序如何为该按钮充气. [英] I am using firebase UI login into my app but when i use Facebook builder it stops the app how to inflate that button..?

查看:72
本文介绍了我正在使用Firebase UI登录到我的应用程序,但是当我使用Facebook Builder时,它停止了该应用程序如何为该按钮充气.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我附上了Java文件,依赖文件和Manifestfile的代码

i am enclosing the code of the Java file, dependency file and Manifestfile

我在外面宣布

 private static final int MY_REQUEST_CODE = 123;
    List<AuthUI.IdpConfig> providers = Arrays.asList(
            new AuthUI.IdpConfig.PhoneBuilder().build(),
            new AuthUI.IdpConfig.FacebookBuilder().build(),
            new AuthUI.IdpConfig.EmailBuilder().build(),
            new AuthUI.IdpConfig.GoogleBuilder().build(),
            new AuthUI.IdpConfig.TwitterBuilder().build());

在此之后我提到了

 Intent intent = AuthUI.getInstance()
                .createSignInIntentBuilder()
                .setAvailableProviders(providers)
                .setLogo(R.drawable.logo)
                .setTheme(R.style.LoginTheme)
                .setTosAndPrivacyPolicyUrls(
                                        "https://example.com/terms.html",
                                "https://example.com/privacy.html")
                .build();

最后我提到了startActivity

and the last i mention the startActivity

startActivityForResult(intent,MY_REQUEST_CODE);

现在这是我的依赖文件

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'  //1.0.2
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    //Firebase
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.firebaseui:firebase-ui-auth:6.2.0'

    //Facebook
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
    implementation 'com.facebook.android:facebook-android-sdk:5.15.1'

    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.google.firebase:firebase-auth:19.3.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    //Cardview and Material
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.1.0' //1.1.0

    //button
    implementation 'info.hoang8f:fbutton:1.0.5'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
}

这是我的清单文件

  <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".Geo_Activity"/>
        <activity android:name=".Profile" />
        <activity android:name=".HomeActivity" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        <meta-data android:name="com.facebook.sdk.ApplicationId"
            tools:replace="android:value"
            android:value="@string/facebook_app_id" />

        <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>

    </application>

现在的问题是,当我将Facebuilder().build()行添加到数组列表中时,应用程序崩溃了

now the problem is that when I add the Facebuilder().build() line into my array list the app is crashed

这是输出屏幕

推荐答案

将您的依赖项更改为:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'  //1.0.2
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

//Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.firebaseui:firebase-ui-auth:6.2.1'

//Facebook

implementation 'com.facebook.android:facebook-android-sdk:5.15.1'



testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//Cardview and Material
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0' //1.1.0

//button
implementation 'info.hoang8f:fbutton:1.0.5'
implementation 'com.google.android.gms:play-services-location:17.0.0'

将这两个strng资源添加到您的strng中:

Add these two strng resources to your strngs :

    <string name="facebook_application_id" translatable="false">APP_ID</string>
<!-- Facebook Application ID, prefixed by 'fb'. Enables Chrome Custom tabs. -->
<string name="facebook_login_protocol_scheme" translatable="false">fbAPP_ID</string>

如果您运行该应用程序,它将立即运行,但是单击Facebook按钮直到获得该应用程序的ID和方案后,用户才能获得身份验证

If you run the app, It will work now, but clicking the facebook button won't get the user authenticated until you get the app id and scheme

要获取应用ID,请登录您的Facebook帐户,访问开发人员页面 https://developers.facebook. com/ 在此处创建一个应用,然后添加"facebook登录",然后按照给出的说明进行操作.您会在您的Facebook应用页面的顶部找到您的应用ID

To get the app id, log into your facebook account, visit the developers page https://developers.facebook.com/ Create an app there, then add the 'facebook login' and then follow the instructions given. You will find your app id in the top of the page of your facebook app

只有两个注释:

  • 您需要将Firebase控制台页面(启用Facebook身份验证时提供的链接)中的"OAuth重定向URI"复制到您的Facebook应用程序设置中

  • You need copy the 'OAuth Redirect URI' from the firebase console page(the link given when enabling facebook authentication) to the settings of your facebook app

您将需要密钥哈希",可以按以下说明获得它: https://stackoverflow.com/a/25524657/9006761 然后,您将其复制到您的Facebook应用设置中

You will need the 'Key hash' which you can be obtained as described here https://stackoverflow.com/a/25524657/9006761 You will then copy it to your facebook app settings

Scheme只是以'fb'开头的应用程序ID

Edit : Scheme is just app id prefixed by 'fb'

这篇关于我正在使用Firebase UI登录到我的应用程序,但是当我使用Facebook Builder时,它停止了该应用程序如何为该按钮充气.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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