Add Firebase to your Android Project – Devstringx

Back to Blog

Add Firebase to your Android Project – Devstringx

Brief Description of Firebase

  • Firebase may be a mobile platform that helps the user quickly develop quality apps.
  • It’s used for developing a new mobile app and implementing an existing app with new functionality to attract the audience.
  • It also provides a Realtime database which is a NoSQL database that store data and sync data.
  • We will also add Authentication Functionality in our android project using Firebase, it has various Sign-in methods like Google, Facebook, Twitter, etc.

All the Sign-in methods are shown below:

Sign method Icon

Add Firebase to Your Android Project

  • First, you have to install or Update Your Android Studio to its latest version.
  • Your project must meet these requirements:
  • Minimum SDK: API 20 (KitKat Wear) or higher.
  • Use Android 4.4W or higher.
  • Use a real device or use an in-built emulator, according to your system configuration.
  • Sign in to Firebase with an existing Google account or create a new one.

Options to Add Your Android Project With Firebase

There are two options for your android project with firebase:

  1. Using the Firebase Setup
  2. Using the Android Studio Firebase Assistant (requires additional configuration)

Option 1: Using the Firebase Setup

 1. Create a Firebase Project:

  • Open Firebase Console, Sign in with your account, and click on add(+) project
  • If you have an existing Google cloud, enter its name or select it from the dropdown
  • For creating a new project, Enter its name
  • Select the Firebase terms and conditions and click on Continue
  • Enable Google Analytics, which offers the optimal experience of firebase products
  • Click on Add Firebase or create a project

2. Add Your App to Firebase:

  • Visit Firebase Console, Click on your added project
  • Click on the android icon to register the app
  • Enter the package name of the project
  • Enter the App nickname or Debug signing certificate SHA-1(optional)
  • Click on the Register app

3. Add Config file to Your Android Project:

  • Download (google-services.json)
  • Add JSON file into your android app root directory

image to add jSON file

  • Make sure that, you have the Google Maven repository in your (Gradle) at the project level.
  • In the (app-level) Gradle file, apply the Google Services plugin:

               apply plugin: ‘com.google.gms.google-services

4. Add Dependencies Into the (app-level) Gradle file

// Add Firebase BoM dependency

implementation platform('com.google.firebase:firebase-bom:30.1.0')  

// Dependency for Google Analytics

implementation 'com.google.firebase:firebase-analytics'

5. Sync your app to download the dependency that you have added.

6. If you are facing any issues throughout the setup, go to Android Troubleshoot

Option2: Using the Android Studio Firebase Assistant

The Firebase Assistant adds the necessary plugins, files, and dependencies to your project.

  • Open your Android Studio and select the project which you want to add to the firebase
  • Select Tools > Firebase
  • In the Assistant panel, Choose the firebase product to add to your app:

navigation to add firbase

  • Click on Connect to Firebase to connect your android app with firebase.
  • Click on the desired product which you want to add to your project (Ex: Add Google Analytics).
  • Now, sync your app to download all the dependencies in your project.
  • You can also add various firebase products to your project, according to the requirements.

Firebase Feature

4. You can add various firebase products like:

  • Add Firebase Authentication.
  • Add Firebase Messaging Services.
  • You can store data in the cloud or in a real-time database.
  • By Crashlytics, You can find when and why your app crashes.

5. That’s it, Your app is successfully connected to the firebase.

6. If you are facing any issues throughout the setup, go to Android Troubleshoot.

FAQs
  • What is the Firebase database in Android Studio?

A real-time database called Firebase enables the storage of object lists organized into trees. Data synchronization between several devices is made possible by it. Add firebase to the android studio is a NoSQL JSON one.

  • Firebase Android Example

A backend platform for creating Web, Android, and iOS applications is Firebase. It provides a hosting platform, many APIs, a real-time database, and various methods of authentication.

  • Why my app is not connecting to Firebase?

Before executing setValue(), you can attach a listener to find out if the client and server are connected and add firebase to your android app.

info/connected

  • How do you check app is connected to Firebase or not?

Go to Project settings Integrations on your add firebase to your android account to see if it is or to enable it. The Google Analytics account is accessible through the email associated with the account you’ll be linking.

If you are interested in even more software testing-related articles and information from us here at Devstringx, then we have a lot to choose from for you.

Share this post

Back to Blog