12.1 Setting up Firebase
Setting up Firebase is very easy and pain free (kinda), just follow these steps! ✨✨
To begin, sign in to the Firebase console. Make sure you use the Google account you want to tie to your project! You should be prompted with a project creation button (or a button to add a project if you've used Firebase before)
Landing screen for Firebase console
Create a project screen
Once on the project home page after creating a Firebase project, you’ll notice several options and details. Here’s where you’ll find the option to add Firebase to an app (hint: click the Android symbol 😊).
Project home landing screen
You’ll see a screen requesting data from your app.
Add Firebase to your Android app
Enter the following information:
- Android Package Name
- App Nickname
- Debug signing certificate SHA-1
The Android Package name should be the applicationId in your module level build.gradle file.
The Debug signing certificate SHA-1 key, while optional, is necessary for some services in Firebase (ie certain authentication features and dynamic linking). The SHA-1 key can be retrieved by opening the terminal in Android Studio in your project and running
Terminal tab highlighted
After registering an app, the next screen prompts you to download a JSON file that contains the service configuration for Firebase. Save it anywhere on your computer and remember where you place it. You’ll add it to the project next.
Landing page for downloading config file
Go into Android Studio and switch to the project view in the left panel:
Add the config file directly under [project name]/app
Next, we have to add corresponding dependencies. Switch back to the Android view in the same left panel:
Open build.gradle, which Android Studio tags as (Project: [project name]). This file is in Gradle Scripts/build.gradle.
Next, add this code in the dependencies section:
Then open Build.gradle, labeled as (Module: [project name]). This file is also in the Gradle Scripts section within the Android view.
Next, add this code under your plugins:
Next, add the following under your dependencies in the same gradle file:
Now celebrate as you've just finished setting up Firebase and the true fun can start ✨✨