Chapters

Hide chapters

Real-World Android by Tutorials

Second Edition · Android 12 · Kotlin 1.6+ · Android Studio Chipmunk

Section I: Developing Real World Apps

Section 1: 7 chapters
Show chapters Hide chapters

19. Firebase Integration
Written by Subhrajyoti Sen

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Building and releasing an app is quite a feat, but you soon realize that it’s just the first step of the process. You need to monitor how your app performs for different users and how your users interact with the app, among other factors, so you can offer the best possible experience.

Traditionally, you’d need different tools for each of these tasks, and building and integrating everything would be tedious. Google addressed those problems by introducing Firebase, a complete suite of services that can help you build your app faster, monitor it in the real world and better engage your users.

In this section, you’ll learn how to use:

  1. The Firebase Console to set up Firebase for your project.
  2. Crashlytics to detect and understand app crashes.
  3. Remote Config to add dynamic content to your app.
  4. Test Lab to perform different tests across a wide range of devices.

You’ll start at the beginning: getting Firebase ready to use.

Setting up Firebase

To set up Firebase, you first need to create a new project at https://console.firebase.google.com. Log in using a Google Account and you’ll see the Firebase Console. Firebase will prompt you to create a new project, as shown below:

Figure 19.1 — Creating a Firebase Project
Figure 19.1 — Creating a Firebase Project

Creating a Firebase Project

Clicking Create a project will bring you to the Create a project page. You’ll see a prompt to provide a project name, as shown below. Enter PetSave.

Mosipe 67.8 — Urnuqr Pefufimo Lnoxadq Bedi
Wobivu 82.6 — Itkivp Ribeguvu Hcumobn Kani

Zorupo 53.7 — Xuoxza Oyawlhosq Fabjinawohaec
Hahoqu 88.5 — Yuagza Asavwgesv Kothexemukuuf

Registering an App

Now that you’ve created your project, you’ll see an option to add Firebase to your app, as shown below:

Mobuqu 36.3 — Ujkotb Rikuquni hu Wuoj Azy
Tiyegu 58.7 — Iydegt Culeqisi ye Qeof Ubz

Defihe 89.3 — Delelgub Wios Ejm
Woqexa 00.2 — Kafexluy Xeiw Atq

Crashlytics

App crashes are among the things developers dread the most. Not only do they prevent the users from using one of the app’s features, but they also create a negative impression. Having a high crash rate leads to lower ratings on the Play Store, more uninstalls and revenue loss.

Setting up Crashlytics

Setting up Crashlytics is straightforward. Still on Android Studio, add the following Gradle plugin to the dependencies block of the project build.gradle:

Testing and Debugging

To test your Crashlytics setup, you need to cause an intentional crash. Do this by opening AnimalsNearYouFragment.kt and adding the following code to onViewCreated:

Geveki 74.8 — Hufuqezexh o Rgixw
Bonero 15.9 — Gesidewokp o Qvoxk

Non-fatal Exceptions

You can also use Firebase to log non-fatal exceptions. In most cases, you log such exceptions locally. While this approach works during development, local logs are useless when the app is on a user’s device. Instead, you’ll log them in Crashlytics.

Yedalo 12.0 — Daxtoqepn u Dic-Vunaf Agkoqvuab Xudp Cgosxqdgewq
Dusati 58.1 — Kinfixubs a Wid-Bidun Uqsowciiw Qoqv Qtevflwgixv

Using Crashlytics With Proguard

You probably enabled Proguard on your release builds before publishing it to the Play Store. In that case, the logs uploaded to Firebase will be obfuscated and, therefore, difficult to read.

Uploading the Mapping File

The Crashlytics Gradle plugin can automatically detect if code is obfuscated and upload the mapping file to the Crashlytics servers accordingly. Though this process is handy, it slows down build times.

Remote Config

As an app developer, you’ll run into situations where you need to change small details in your app from time to time. Making a new release for a small change is cumbersome, especially since Play Store can take anywhere from a few hours to a few days to update. For these cases, Firebase provides Remote Config.

Setting up Remote Config

You can treat Remote Config as a read-only entity that’s unaware of the implementation details of the app. You can also treat it as a source of key-value pairs.

Adding a Config

Open fragment_secret.xml. You’ll notice an android:src attribute specifying the image to display. Remove the attribute and add an id to the ImageView, as follows:

Using a Dynamic Value to Update the UI

The only thing left to do on the app side is updating SecretFragment.kt to use the updated value and setting the image in the ImageView.

Kunosi 88.3 — Bumbawd Wugane Veppik
Redobu 35.2 — Dobhafl Tucope Biztoc

Updating the Remote Config Value

To update the value of any Remote Config key, open the Firebase Console and select the Remote Config option from the left navigation bar. It’s in the Engage section.

Vaviko 08.2 — Qjaelo Zafxonodeguex Vebcuv
Mokuvi 42.9 — Bzuune Fiwgaviquheom Tarmeg

Tudepe 12.07 — Ecy a Nuw Jibulihex fa Bowuni Qohnel
Mohoga 04.49 — Azv e Qaq Nafizewef mu Nedate Lacyej

Wapulo 17.44 — Owxigsilx Rxicvuy
Dawina 86.05 — Iybalpaxp Khighul

Rivobu 68.55 — Hutqaxh Mudzahitexuur Wvojgan Yanz Kufibo Femjif
Vakapo 59.16 — Gonroqx Qadzipedediaf Tbuhjih Feln Loteto Nuvlan

Firebase Test Lab

Android is a highly fragmented operating system. It runs on thousands of different device variants, and each manufacturer makes its own changes. The way an SDK works on a Pixel device can differ from how it works on a Xiaomi device. Additionally, Android brings out a new version each year, and with each new release, many APIs change. Given all these variations, you’ll need to test your app on devices with different Android versions and from different manufacturers.

Running Your First Test

To run your first test on Test Lab, visit the Firebase Console and select Test Lab from the navigation bar on the left. It’s in the Release & Monitor section.

Duyujo 83.92 — Votyuzr Mwosxoj Kiqf Wetg Bic
Wayogu 88.37 — Mulbinh Tvowfiw Pamk Puzb Zos

Zapaje 17.83 — Yibr Hiv Veyuagj Cimt Hosnel
Mahoja 91.44 — Woxs Sub Xibuanl Kasb Pityim

Creating a Robo Test Preset

A test preset is like a template that you can use to run your tests instead of configuring the options every time. A preset consists of the following:

Xajemi 65.05 — Boxj Pax Seg Hyekit
Zotoji 57.19 — Wufj Wuc Bas Pqopep

Medihu 50.52 — Fuxzesigu Soav Gicc Dulrar
Zupoza 35.46 — Kurropepa Leen Xowk Heqmoy

Creating an Instrumentation Test Preset

An instrumentation test preset differs from a Robo test preset only in the Additional options section. To create an instrumentation test preset, select Instrumentation test as the Test type and expand Additional options. There are three options in this category:

Running a New Test

To run a new test, visit the Test Lab dashboard and click Run a test. Select the type of test you want from the drop-down menu.

Gihixi 56.20 — Zowu Cyvews Qumfihehewauc
Tipalo 58.12 — Buho Mljevk Hekwijukumeew

Key Points

  • Crashlytics is easy to set up and can play a big part in keeping your app’s crash rate under control.
  • Use Crashlytics to log non-fatal exceptions.
  • Use Remote Config to introduce dynamic content and behavior in your app.
  • Evaluate when it’s appropriate to activate the Remote Config values to provide a good user experience.
  • Test Lab lets you run both Robo and Instrumentation tests on a wide range of devices.
  • Use Orchestration and Sharding to get faster and more reliable test results.
Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2026 Kodeco Inc.

You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now