How to connect an Android App to Firebase (Firebase Tutorial #1)


What is Firebase?

Firebase is a platform backed by Google which offers a range of products that can help you build better apps, improve app quality and grow your business.

Products offered by Firebase are listed below:

  • Cloud Firestore: Store and sync app data on a global scale.
  • ML Kit: Machine learning for mobile developers.
  • Cloud Functions: Run mobile backend code without managing servers. To know more click here.
  • Authentication: Authenticate users simply and securely.
  • Hosting: Deliver web app assets with speed and security.
  • Cloud Storage: Store and serve files at Cloud without worrying about scalability.
  • Realtime Database: Store your app data and sync them in seconds.
  • Crashlytics: Prioritize and fix issues with powerful, realtime crash reporting.
  • Performance Monitoring: Gain insight into your app’s performance.
  • Test lab: Test your app on devices hosted by Google.
  • App Distribution: Distribute pre-release versions of your app to your trusted testers.
  • In-app Messaging: Engage active app users with contextual messages.
  • Google Analytics: Get free and unlimited app analytics.
  • Predictions: Smart user segmentation based on predicted behavior.
  • A/B Testing: Optimize your app experience through experimentation.
  • Cloud Messaging: Send targeted messages and notifications.
  • Remote Config: Modify your app without deploying a new version to Playstore.
  • Dynamic Links: Drive growth by using deep links with attribution.

Connect an Android app to FireBase

Today in this tutorial, we are going to learn how to connect an Android app to Firebase.

Step 1

Open Firebase Console and click on Add Project.

Add project to Firebase

Step 2

Enter your project name, check the user agreement and click on Continue.

Enter project name

Step 3

Make sure the option Enable Google Analytics for this project is enabled. Click Continue.

Enable Google Analytics in Firebase

Step 4

On the Configure Google Analytics screen, select Default Account for Firebase from the dropdown and click Create project.

Configure Google Analytics for Firebase

Step 5

Now, click on the Android icon to proceed with adding your Android app to this Firebase project.

Add Android app to Firebase

Step 6

Enter the package name of your app and click on Register app.

Add package name of your Android app

Step 7

Click on the Download google-services.json button and once the JSON file gets downloaded, place it inside the app folder of your Android project.

Download google-services.json from Firebase

Step 8

Click on next and it will show you the dependencies that you need to add to your Android project.

Add Firebase dependencies to your Android project.

Copy the dependency marked with number 1 to your project level build.gradle file and copy the dependencies marked with number 2 and 3 to your app level build.gradle file as shown in the screenshots below.

Finally, click on Sync Now in the bar that appears in Android Studio.

Step 9

Click on the Next button and then select the Skip this step option. Congratulations, your Android app is now connected to the Firebase.

That’s it for now. In the next tutorial, we will learn how to integrate Email and Google Login using Firebase.

About the author

Mehul Kanzariya

Passionate about Android Development and all things tech.

Recommended Host

Siteground hosting Covid19 offers

Top Posts