Introduction
Google Firebase is trending nowadays. It has around 10 sign-in methods which include email, Google, Facebook, Phone, Twitter, and Yahoo login etc. We have covered Email/Password and Gmail Login in another article. If you want to know more about it, then you can check here. We are covering the Facebook Login in this article. Now, we are going step by step. I have given my git repository link in the bottom as well.
Create a new Flutter Application
The first and basic step is to create a new application in Flutter. If you are a beginner in Flutter, you can check my blog Create a first app in Flutter. I have created an app named as “flutter_fb_login” here.
Create a Facebook App in Facebook Developer Console
For Facebook Login in Flutter, you need to create a Facebook app in the Facebook Developer Console. For that, follow the below steps.
- Go here and login using your Facebook account or create a new one.
- Then, create a new app using MyApp => Create App, give an app name and create the app. Check out the below screenshot.


- After creating the app, click on "Integrate Facebook Login" and Confirm.
- Go to the Dashboard tab. Under "My Products", you will find Facebook Login=>Settings (click on that).
- Then, on the left side, you will find QuickStart under Facebook Login menu. Just click on it.
- Select Android.

- On the next two screens, just click "Next". After that, you will get a screen asking for your Android project. Give the package name and default Activity Class name as I have given in the below screenshot. And go to Save => Use This Package => Continue.

Package Name: com.example.flutter_fb_login
Default Activity: com.example.flutter_fb_login.MainActivity
- On the next screen, you need to add your development and release key hashes. Follow Mac or Windows as per your OS and enter the hash key. Please note that the default Android Keystore password is "android". Copy the hash key and paste there and go to Save => Continue.
- Now, click "Next".
- Next, you need to put a lot of stuff in your app.
- Go to your project's android/app/src/main/res/values folder. Under the Values folder, create a new file named strings.xml and put the below string (you have in your Facebook project ) in this file.
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <string name="app_name">flutter_login</string>
- <string name="facebook_app_id">2432431656989926</string>
- <string name="fb_login_protocol_scheme">fb2432431656989926</string>
- </resources>
- Then, go to android/app/src/main/AndroidManifest.xml and paste the below code (you have in your Facebook project) under first activity and in the application tag. Please check the screenshot for better undestanding.

- Click "Next" for all further screens.
- You are all done with the Facebook App Setup. Congratulations…. :)
Set up a project in Google Firebase
Now, you need to set up a project in Google Firebase. Follow the below steps for that. Please follow the steps very carefully.
- Go here and add a new project. I will share the screenshot of how it looks so you will get a better idea.
- Click on "Add Project" to add a new project in Google Firebase. Then, you will find the below form.


- Give a project name and accept the terms and condition and click "Create Project". It will take some time to create a new project and redirect you to the Project Overview page.
- Now, you need to add an Android app to this project. You can add a new Android project by clicking on the Android icon. You can also add an iOS project if you want to create the iOS application for the same.

- In Project Overview, add an Android app. For that, click on the Android icon. It will open a new form.

- You will find the Android package name in the AndroidManifest.xml file in Android => App => main folder of your project.
- App nickname is optional
- For SHA-1 generation, go here.
- Now, download the google-service.json file and put in the Android => App folder of your project.
- Next, you need to configure some dependencies.
Project-level build.gradle (<project>/build.gradle): means build.gradle file in the Android folder directly.
App-level build.gradle (<project>/<app-module>/build.gradle): means build.gradle file in Android = > App folder- buildscript {
- dependencies {
- // Add this line
- classpath 'com.google.gms:google-services:4.2.0'
- }
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services’
Note
Don’t need to add implementation 'com.google.firebase:firebase-core:16.0.9' in dependencies
- In the next step, it will try to verify your app. For that, you need to run your app once or you can skip this step.
- Hurray! Your Android app has been created.






Bert BeckmnannPosted Aug 28, 2019, 2:12 PM
Hi- I'm having build errors for ios. One error is: "Use of undeclared identifier 'FBSDKLoginBehaviorNative';". I tried to check the git repo above (https://github.com/myvsparth/firebase_fb_login) but it doesn't exist.