Book Image

Mastering Firebase for Android Development

By : Ashok Kumar S
Book Image

Mastering Firebase for Android Development

By: Ashok Kumar S

Overview of this book

Firebase offers a wide spectrum of tools and services to help you develop high-quality apps in a short period of time. It also allows you to build web and mobile apps quickly without managing the infrastructure.Mastering Firebase for Android Development takes you through the complete toolchain of Firebase,including the latest tools announced in Google IO 2018 such as Firebase ML-Kit, FireStore, and Firebase Predictions. The book begins by teaching you to configure your development environment with Firebase and set up a different structure for a Firebase real-time database. As you make your way through the chapters, you’ll establish the authentication feature in Android and explore email and phone authentication for managing the on-boarding of users. You’ll be taken through topics on Firebase crash reporting, Firebase functions, Firebase Cloud, Firebase Hosting, and Cloud Messaging for push notifications and explore other key areas in depth. In the concluding chapters, you will learn to use Firebase Test Lab to test your application before using Firebase Performance Monitoring to trace performance setbacks. By the end of the book, you will be well equipped with the Firebase ecosystem, which will help you find solutions to your common application development challenges.
Table of Contents (23 chapters)
Title Page
Copyright and Credits
Packt Upsell
Application Usage Measuring and Notification, Firebase Analytics, and Cloud Messaging
Bringing Everyone on the Same Page, Firebase Invites, and Firebase App Indexing
Making a Monetary Impact and Firebase AdMob and AdWords
Flexible NoSQL and Cloud Firestore
Analytics Data, Clairvoyant, Firebase Predictions


Firebase is a very popular Backend-as-a-Service (BaaS) tool launched in April 2012. Because of its state-of-the-art capabilities and technology such as its real-time database, it caught the interest of Google and was acquired by Google in 2014. I started to explore Firebase technologies before Google's acquisition. Now, Firebase has transformed into a powerful tool, containing support for most of the use cases of real-world software development. Firebase divides the toolchain into three distinct categories: build your application, improve the application's quality, and grow your business.

The book introduces all the tools with quick code snippets, and also, in a couple of chapters you get to run programs as quick simple projects. The book will give you complete comprehension of what Firebase has to offer for Android developers by tailoring features and code snippet examples in every chapter.

Since Firebase, it has become easy to build a great mobile application, be it iOS or Android. Firebase has a lot of things to offer, from analytics to user acquisition and A/B testing, and the list goes on. This book will cover the most up-to-date information on Firebase, including the latest tools that were introduced in Google IO 2018.

Who this book is for

The book can be used by any developer who has basic knowledge of building mobile or web applications. Though the book targets Android developers, there are chapters on Firebase functions and hosting that can help web developers too.

What this book covers

Chapter 1, Keep It Real – Firebase Realtime Databaset, will introduce configuring the development environment and deep dive into the popular Firebase feature, the real-time database.

Chapter 2, Safe and Sound – Firebase Authentication, demonstrates how to use the multi-platform sign-in feature available in Firebase. Developers will be able to explore email authentication, social login, phone number authentication, and more.

Chapter 3, Safe and Sound – Firebase Crashlyticsdemonstrates the Firebase crash reporting feature in detail, along with how to diagnose and fix bugs, and how to generate detailed error reports

Chapter 4Genie in the Cloud – Firebase Cloud Functions, contains comprehensive examples and an overview of Firebase functions. Firebase functions is still in beta and the active development phase, but it is already a jaw-dropping technology.

Chapter 5, Arsenal for Your Files – Firebase Cloud Storage, consists of comprehensive examples and an overview of Firebase cloud storage. Firebase cloud storage helps store and serve content with ease. This chapter will show how to store different mime type files ranging from photographs to videos. 

Chapter 6, Not Just a Keeper, Firebase Hosting, comprises comprehensive examples and an overview of Firebase Hosting. Firebase Hosting is a very handy feature for hosting websites. Firebase Hosting has low latency and Global CDN with a free SSL certificate.

Chapter 7, Inspection and Evaluation – Firebase Test Lab, contains comprehensive examples and an overview of Firebase Test Lab for Android. This cloud-based infrastructure helps developers to test their products on different use cases. Test Lab can test applications remotely on different devices.

Chapter 8, A Smart Watchdog – Firebase Performance Monitoring, explains the process of diagnosing an application's performance issues. Using the trace feature, we will be able to monitor specific bugs and avoid performance setbacks. 

Chapter 9, Application Usage Measuring and Notification, Firebase Analytics, and Cloud Messaging, explains how to measure an application's usage and send and receive push notifications.

Chapter 10, Changing Your App – Firebase Remote Config and Dynamic Links, explains that Firebase Remote Config lets you change the behavior and appearance of your application. Dynamic links are very useful in terms of presenting the content to different platforms.

Chapter 11, Bringing Everyone on the Same Page, Firebase Invites, and Firebase App Indexing, and Firebase App Indexing, explores sending and receiving invites from your mobile app. Also, App index helps get public and personal content from your app into users' search results.

Chapter 12, Making a Monetary Impact and Firebase AdMob and AdWordshelps developers inflate in-app advertisements and improve the user experience. You will access monetization reports using AdWords developer, and will learn how to reach potential customers with online ads. 

Chapter 13, Flexible NoSQL and Cloud Firestore, helping developers to write next-generation Firebase applications.

Chapter 14, Analytics Data, Clairvoyant, Firebase Predictions, demonstrates the power of Firebase Predictions, which runs the advanced machine learning algorithms by predicting the next action before it takes place.

Chapter 15, Train Your Code and ML-kit, illustrates the power of ML-kit by explaining its features. You also will write an application to perform text recognition in a photograph captured through your phone's camera. 

To get the most out of this book

To master Firebase, you need to have fundamental knowledge of platforms such as iOS, web, and Android. The book mostly targets Android developers, and at the time of writing, the following assumptions were made for the reader:

  1. How to install the latest version of Android Studio
  2. Has Google official credentials for Firebase
  3. An intermediate developer who can understand Java and Kotlin syntax
  4. Little experience of CLI tools and Node.js syntax

The book also has a little for web developers if you are a beginner and want to explore how to host your website and you want to understand a little bit about writing Node.js code that can trigger an action. 

Download the example code files

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at Check them out!


Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

FirebaseUser user =FirebaseAuth.getInstance().getCurrentUser();
if(user !=null){
// When User is signed in
// When user is not signed in

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

myTrace = FirebasePerformance.getInstance().newTrace("packt_trace")
val bundle = Bundle()
bundle.putString("oncreate", "created")
mFirebaseAnalytics?.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle)

Any command-line input or output is written as follows:

npm install -g firebase-tools

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit


Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit