Unable to Sign in Through Facebook in Flutter App

3.3k views Asked by At

I want to use Facebook Sign-in in my Flutter app. For this, I'm using the Flutter package flutter_facebook_auth 4.3.0. And configure my android app on my Facebook developer account. When the application started or I tried to make a Sign in request: I'm getting this message:

E/com.facebook.GraphResponse( 3869): {HttpStatus: 400, errorCode: 190, subErrorCode: -1, errorType: OAuthException, errorMessage: Error validating application. Invalid application ID.}

1

There are 1 answers

0
Emil Helgren On

I had the exact same problem, and now I finally found a solution, so here is what worked for me.

TL;DR

  1. Make sure to have this in your Android Manifest file:

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

    Along with the strings.xml file with the app id mentioned in the Facebook Login documentation.

  2. Comment out this line in your app level build.gradle file:

    implementation 'com.firebaseui:firebase-ui-auth:7.2.0' // comment this out!
    

Explanation: A problem that occured before the problem you mention, was that having the reference to the application ID from strings.xml in your Android Manifest as described in the Facebook login documentation like this:

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

caused this build error:

Attribute meta-data#com.facebook.sdk.ApplicationId@value value=(@string/facebook_app_id) from (unknown)
is also present at [com.firebaseui:firebase-ui-auth:7.2.0] AndroidManifest.xml:21:13-60 value=(@string/facebook_application_id).

And the "solution" mentioned on an old Github post (reference missing) stated that you should just comment the reference out in your Android Manifest - and sure enough this removed the build error, but then another problem came.

The new issue that came along was basically that during the bulid, a Facebook application ID of "CHANGE-ME" was written for the string value that should have been read from your strings.xml - you can see this in VScode if you just search for "CHANGE-ME", then you'll find a value.xml file containing this wrong ID, and even if you change it in this file it doesn't solve the problem.

What solved the issue for me was commenting out the implementation causing the clash resulting in the build error instead, which is in your app level build.gradle:

implementation 'com.firebaseui:firebase-ui-auth:7.2.0' // comment this out!

And leave in the reference to your strings.xml app ID in your Android Manifest file, so the application ID is written correctly.

I have tested all the firebase functionality I use in my app to see if any issues came from commenting this out, but I haven't found any issues yet. I use and have tested these features after commenting out:

  • Realtime database
  • Email/password sign in
  • Google Sign in
  • Facebook Sign in

Hope this helps.