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
Dedication
Packt Upsell
Contributors
Preface
9
Application Usage Measuring and Notification, Firebase Analytics, and Cloud Messaging
11
Bringing Everyone on the Same Page, Firebase Invites, and Firebase App Indexing
12
Making a Monetary Impact and Firebase AdMob and AdWords
13
Flexible NoSQL and Cloud Firestore
14
Analytics Data, Clairvoyant, Firebase Predictions
Index

Setting up a development environment 


To get started, we need to integrate the Firebase SDK to the project, and it is a one-time integration. Later, we can choose any of the Firebase tools that we want to work with and add the appropriate gradle dependency. 

Prerequisites 

To develop Firebase applications, you can surely use your development environment; the essential requirements are as follows:

  1. Your favorite operating system (Windows, macOS, or Linux)
  2. Determine whether you have the latest JRE installed on your operating system
  3. Install the latest version of JDK or Open JDK
  4. Install the newest version of Android Studio (at the time of writing, the most recent stable version is 2.3.3 and 3.0 is still in beta, or any newer version should also be excellent)
  5.  Android SDK with one complete API will be very significant

Note

Before we continue to create our first Firebase Realtime Database Android application, ensure that you have one complete version of Android API installed, and you have the latest version of Android Studio.

Configuring Firebase in Android projects

There are two ways that you can connect Firebase to your Android project, from the Firebase console creating the new project and adding the dependencies and Google config file. The other way is just to add Firebase support to an Android project directly from Android Studio:

  1. The usual way of connecting Firebase is to visit the Firebase console at https://console.firebase.google.com/
  2. Create a new project using the Add Project button, and if you already have an existing project, you are free to choose it
  3. In the overview section of the console, you can choose to add an Android application by clicking on the relevant button and add the necessary information to the fields
  4. Download the google-services.json file, add it to your project's app folder root, and the classpath gradle dependencies in the project's gradle file
  5. To reduce the effort, we can make Android Studio do all this for us by choosing the Tools Firebase menu option and clicking on the Firebase tools that you want to integrate from the list
  6. After you chose the Firebase tool, tap on Save and retrieve data
  7. In the next window panel, you will see options such as Launch in the browserConnect your app to Firebase, and so on, click on theConnect your app to Firebasebutton and select your project or you can create the new project in the Connect to Firebase window
  8. Go back to the Firebase panel and click on theAdd the Realtime Database to your applicationbutton

Since we have connected to Firebase, it is as simple as it sounds, all we have to do is select the Add the Realtime Database to your application button in the Firebase assistance window, you will see a dialog for requesting your authorization to change the gradle file with a few dependencies. Tap on Accept Changes, now we are all set to explore Realtime Database abilities.