简体   繁体   English

我正在使用 firebase UI 登录到我的应用程序,但是当我使用 Facebook 构建器时,它会停止应用程序如何为该按钮充气..?

[英]I am using firebase UI login into my app but when i use Facebook builder it stops the app how to inflate that button..?

i am enclosing the code of the Java file, dependency file and Manifestfile我附上了 Java 文件、依赖文件和清单文件的代码

i declared outside我在外面宣布

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

after this i mentioned this在这之后我提到了这个

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

and the last i mention the startActivity最后我提到了 startActivity

startActivityForResult(intent,MY_REQUEST_CODE);

now this is my Dependencies File现在这是我的依赖文件

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'
}

after this it is my Manifest file在此之后这是我的清单文件

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

now the problem is that when I add the Facebuilder().build() line into my array list the app is crashed现在的问题是,当我将 Facebuilder().build() 行添加到我的数组列表中时,应用程序崩溃了

this is the output screen这是 output 屏幕输出

Change your dependencies to:将您的依赖项更改为:

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'

Edit:编辑:

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>

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如果您运行该应用程序,它现在可以工作,但单击 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.要获取应用程序 ID,请登录您的 facebook 帐户,访问开发人员页面https://developers.facebook.com/然后按照给出的说明添加并创建应用程序。 You will find your app id in the top of the page of your facebook app您将在 facebook 应用程序的页面顶部找到您的应用程序 ID

Just two notes:只需两个注意事项:

  • 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您需要将“OAuth Redirect URI”从 firebase 控制台页面(启用 facebook 身份验证时给出的链接)复制到 Z26CAE7718C32180A7A0F8E19D6D40A5 的设置中

  • 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您将需要“密钥哈希”,您可以按照此处的说明获取该密钥https://stackoverflow.com/a/25524657/9006761然后将其复制到您的 facebook 应用程序设置

Edit: Scheme is just app id prefixed by 'fb'编辑:方案只是以'fb'为前缀的应用程序ID

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试从我的 HomeActivity 扩展菜单,但是当我单击列表中的任何项目时应用程序崩溃 - I am trying to inflate a menu from my HomeActivity but the app crashes when i click any of the items on the list 如何从我自己的应用程序运行另一个应用程序? 例如,当我单击应用程序中的按钮时,我想运行Facebook - How to run another app from my own app? For example, I want to run Facebook when i click on a button in my app 我在 android 上开发一个应用程序,每次单击按钮时都会处理 sqlitedatabase 我的应用程序停止这是 logcat 消息和代码 - am developping an app on android handling sqlitedatabase every time I click on a button my app stops this is the logcat msg and the code 单击注册按钮时应用程序崩溃(使用 firebase ) - App crashes when I click signup button (using firebase ) 为什么我按下按钮后我的应用程序停止运行 - Why does My app stops after i press the button 当我第二次按下按钮时,应用程序停止工作 - When I press second time on the button , the app stops working 将 Firebase 应用与 Google Sign In 结合使用时,如何使用我的 Google Cloud Function 进行身份验证? - How do I authenticate with my Google Cloud Function when using my Firebase App with Google Sign In? 我在使用 Firebase 创建注册时出错 我的应用程序实际上正在运行,但是当我按下注册按钮时它一直显示失败 - I'm having an error creating an registration using Firebase My app is actually running but when I pressed on register button It keep on showing fail 单击Facebook登录按钮会使应用程序崩溃 - Facebook Login Button crashes app when clicked 我怎么会出现身份验证错误,但是当我通过应用程序登录时,我能够登录 - How come I'm getting authenticate error, but when I login via the app, I am able to log in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM