Skip to main content

[Make-A] Simple Chat Application using Cloud Firestore Part 2 – Setting up Firebase Cloud Firestore

Table of Contents

  1. Part 1 – Specs and Introduction
  2. Part 2 – Setting up Firebase Cloud Firestore
  3. Part 3 – Adding a Simple Authentication
  4. Part 4 – Adding a FloatingActionButton (FAB)
  5. Part 5 – Creating a Chat Room
  6. Part 6 – Entering The Chat Room
  7. Part 7 – Displaying The Chat Rooms
  8. Part 8 – Chat
  9. 10 Exercises and Thanks!

Before we can setup Firebase Cloud Firestore, we need to setup our project first for Firebase.

1. Creating a new project in Android Studio

1. Create a new project in Android Studio through File -> New Project and select Empty Activity as your template.

2. Set your Application name to FirebaseChat or any name that you want.

2. Creating a new project in Firebase

1. Go to https://console.firebase.google.com/

2. Add Project

3. Set the project name to FirebaseChat or any name that you want.

4. Choose your country

5. Click Create Project

3. Adding Firebase to your Android app

After you have created your project, you will be redirected to your project console.

1. Click Add Firebase to your Android app

2. Enter the package name of the project that we created in Android Studio.
If you don’t know your package name, open your app-level build.gradle under app/ directory and look for applicationId.

3. Click Register App

4. Download your google-services.json file and follow the instructions provided. Copy the google-services.json file that you just downloaded and paste in under app/ directory as seen from the instructions.

5. Click Continue.

4. Adding Firebase gradle dependencies

After you click continue, you will be given instructions on how to the gradle dependencies.

1. In your project-level build.gradle file:

buildscript {
    ...
    dependencies {
        ...
        // Add this line
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

As of this writing, the latest google services version is 3.2.0. Make sure to use the latest version as seen in the instructions provided by Firebase.

The latest version of  Firebase libraries can be found under available libraries.

2. In your app-level build.gradle file:

dependencies {
    ...
    // Add this line
    implementation 'com.google.firebase:firebase-core:12.0.1'
}

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

3. Click sync now

5. Adding Firebase Cloud Firestore

1. In your app-level build.gradle file:

dependencies {
    ...
    // Add this line
    implementation 'com.google.firebase:firebase-firestore:12.0.1'
}

 

Now that our project is setup for Firebase Cloud Firestore, it’s time to implement our authentication feature.