Finish the setup of a Firebase project for an Android app tutorial (step by step)

AndroidCrypto
4 min readDec 24, 2023

--

This tutorial is about finishing the set up the of a Firebase project for an Android app, but not for a product like “Authentication” or “Database” — see the separate tutorials for these products (links at the end of this article). And there is no code for an Android app or Web app (see the links to my other articles for this topic).

A ote when setting up a Firebase project for an Android app that is developed by another guy (e.g. by using a GitHub repository of a developer). You should change the given package name to something own before setting up the Firebase project, because the developer already made a Firebase setup with the given package name and Firebase will refuse this package name a second time. E.g. the package name of my project is “de.androidcrypto.firebasecloudmessaging” — you can change it to “com.mypackage.firebasecloudmessaging” and then setup the project.

In the Project Overview click on “Project settings”:

Scroll down and click on the Android icon to add an app:

For this step we need to retrieve 2 information about our app and our development environment.

The first information is the Android package name — go to Android Studio, open your app, open your build.Gradle (module :app) file and copy the package name from “defaultConfig” section in “ applicationId“ (in my example it is “com.firebase.quickstart.auth”).

The second information is an app nickname — just use your app name or Firebase project name.

The third information is a little bit tricky — you need to get the “Debug signing certificate SHA-1”). It is named as optional, but later (in the “Setup Authentication tutorial”) it is necessary for Google Sign-in, so it is a good idea to retrieve the data and enter them at this point. In most tutorials there are a lot of ways shown to get the data but not the one I’m presenting here. I’m using a Gradle report called “signingReport”. Click on the Gradle tab in Android Studio:

Click on the “play” symbol and a new window opens:

Type in “signingReport” and press “Enter”. In the console you will find a very long report but there is just one line of interest (the one starting with “SHA1”):

...
Variant: debug
Config: debug
Store: /Users/xxx/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 4D:1E:D7:91:56:67:73:EA:54:73:BC:EC:D7:E5:9B:F5
SHA1: 19:22:A4:D7:01:A8:3D:09:8F:04:93:E9:8E:21:92:2D:5A:5F:B0:54
SHA-256: A7:A8:66:27:C7:76:6D:C3:3C:9E:3F:89:99:88:3E:A1:7B:ED:34:69:19:83:B6:EA:72:04:C9:13:8E:84:E0:90
Valid until: Samstag, 30. September 2051
...

Just copy the data (beginning with 19:…) and paste it the the last field, then press “Register app”.

Now it takes some seconds and then we are ready:

We need to download the “google-services.json” file and move it to the app folder of our project (not to the sub folder src !):

Please note: the “google-services.json” file holds some informations about the products included in the app, so I recommend to download the file after you added the products to your project.

Second note: The data in the json file has confidential credentials so you might consider to add an entry to the “.gitignore” file in Android Studio:

*.iml
.gradle
...
google-services.json

Don’t forget to add the necessary dependencies to the “Gradle.build” files.

Article series about Firebase:

  1. Setup of a Firebase project
  2. Setup of Firebase Authentication (this article)
  3. Setup of a Firebase Realtime Database
  4. Setup of a Cloud Firestore Database
  5. Setup of Firebase Storage
  6. Finish the setup of the Firebase project for an Android app tutorial (step by step) (this article)
  7. Finish the setup of the Firebase project for a Web app tutorial (step by step): will follow soon
  8. Firebase tutorial for an Android app (Java): will follow soon
  9. Firebase tutorial for a Web app (Javascript): will follow soon

--

--