skip to Main Content

I’ve followed the Authenticate using Facebook Login guide.
When I reached “Authenticate with Firebase” it says I should follow the Facebook developer’s documentation.
As soon as I added the facebook_app_id in the Androidmanifest, which is in 4. Edit Your Resources and Manifest, step 4:

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

I got an error:

Manifest merger failed : Attribute meta-data#com.facebook.sdk.ApplicationId@value value=(@string/facebook_app_id) from AndroidManifest.xml:52:13-52
    is also present at [com.firebaseui:firebase-ui-auth:4.3.1] AndroidManifest.xml:21:13-60 value=(@string/facebook_application_id).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:50:9-52:55 to override. 

It seems strange to add the key anyway, because I use Firebase so that I have an automatic drop-in UI, I’m expecting Firebase to handle this for me. The firebase documentation also says “If you integrated Facebook Login using a LoginButton” why would I want this? The whole reason you implement the firebase UI is so that you don’t have to add a button etc.

When I remove facebook_app_id, then I get below error:

E/GraphResponse: {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Object with ID '1234567890' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}

This seems to be the problem. This is the method:

override suspend fun makeSignInIntent(): Intent {
    return withContext(ioDispatcher) {
        // Choose authentication providers
        val providers = arrayListOf(
            AuthUI.IdpConfig.EmailBuilder().build(),
            AuthUI.IdpConfig.GoogleBuilder().build()
//                AuthUI.IdpConfig.FacebookBuilder().build()
        )
        // Create and launch sign-in intent
        AuthUI.getInstance()
            .createSignInIntentBuilder()
            .setAvailableProviders(providers)
            .build()
    }
}

Please note that I excluded AuthUI.IdpConfig.FacebookBuilder().build() and still get the error.

Here is my build.gradle:

implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
implementation 'com.firebaseui:firebase-ui-database:6.2.0'
implementation "com.google.firebase:firebase-auth:19.2.0"
implementation "com.google.firebase:firebase-database:19.2.0"
implementation 'com.facebook.android:facebook-android-sdk:5.13.0'
implementation 'com.facebook.android:facebook-login:5.13.0'

My strings.xml:

<!-- Facebook application ID and custom URL scheme (app ID prefixed by 'fb'). -->
<string name="facebook_application_id" translatable="false">MY_KEY</string>
<!-- Facebook Application ID, prefixed by 'fb'. Enables Chrome Custom tabs. -->
<string name="facebook_login_protocol_scheme" translatable="false">fbMY_KEY</string>

I’ve enabled Facebook login and added the necessary keys:

enter image description here

I also added the redirect URI and the Development Key Hash:

enter image description here

UPDATE: Also tried this documentation, but is the same.

2

Answers


  1. I had the same issue. I resolved it by adding

    <string name="facebook_application_id">MY_KEY</string>
    <string name="facebook_app_id">MY_KEY</string>
    <string name="fb_login_protocol_scheme">fbMY_KEY</string>
    

    To the strings.xml file and I changed the meta-data to include a tools:replace:

    <meta-data android:name="com.facebook.sdk.ApplicationId"
        tools:replace="android:value"
        android:value="@string/facebook_app_id"/>
    
    Login or Signup to reply.
  2. In your string.xml file declare resources follow:

    <string name="facebook_application_id" translatable="false">YOUR_ID</string>
    <string name="facebook_login_protocol_scheme" translatable="false">fbYOUR_ID</string>

    In App build.gradle, add at least dependencie 8.2+ version :

    implementation 'com.facebook.android:facebook-android-sdk:8.2+'

    Finally in your providers from Activity add:

    List<AuthUI.IdpConfig> providers = Arrays.asList(new AuthUI.IdpConfig.FacebookBuilder().build());

    I hope to have help you

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search