# 10.1 Setting up Firebase

### Creating a Firebase Project in the Console

&#x20;To begin, sign in to the [Firebase console](https://console.firebase.google.com). 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](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbkHp43nS7FHbUwyXY%2Fimage.png?alt=media\&token=7317fd97-8c47-478e-a204-ff923837cc18)

![Create a project screen](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYblIgDESglOkBkq-US%2Fimage.png?alt=media\&token=9a4ef42d-2fc9-4345-992f-7e90eac76354)

### Registering the App With Firebase

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](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbn7pKdz9nUwr1_qCn%2FScreenshot%202021-04-18%20214057.png?alt=media\&token=6cc235d6-4732-46cd-8d10-73b013da80de)

You’ll see a screen requesting data from your app.

![Add Firebase to your Android app](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbmzV3AV_64kRVrequ%2Fimage.png?alt=media\&token=e61eb273-5623-4b86-b9c6-5282e5692c25)

Enter the following information:

* Android Package Name&#x20;
* App Nickname
* Debug signing certificate SHA-1

The Android Package name should be the applicationId in your module level *build.gradle* file.&#x20;

\
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&#x20;

```
gradlew signingReport
```

![Terminal tab highlighted](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbp9xwxM7P_o_6OKxf%2Fimage.png?alt=media\&token=672d675e-1aed-4295-8260-0d0a8a3b2221)

### Adding Firebase Configuration Files to Your Android Project

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](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbs5vjkZAIUisb_CYP%2Fimage.png?alt=media\&token=458d3294-c195-4558-bdce-e27241eec883)

&#x20;Go into Android Studio and switch to the *project view* in the left panel:

![](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbstt_zmKcduOM_wK9%2Fimage.png?alt=media\&token=193a1e8a-cd8f-48fb-b4f8-dd7bd0716f9b)

Add the config file directly under \[project name]/app&#x20;

Next, we have to add corresponding dependencies. Switch back to the *Android view* in the same left panel:

![](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbuAdKYWXG7Jn0dSQH%2Fimage.png?alt=media\&token=3ed50101-987f-465b-b8e4-c4a657bf583d)

&#x20;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:

```
classpath 'com.google.gms:google-services:4.3.3'
```

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:

```
id 'com.google.gms.google-services'
```

![](https://195521982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LvOeSx5ZqjJA8sxykMu%2F-MYbjKLUwrrYyatuEhK0%2F-MYbujstY0M1K2ggZwNK%2Fimage.png?alt=media\&token=d0b4c01f-03b5-4822-b448-07df5a38b556)

Next, add the following under your dependencies in the same gradle file:

```
implementation platform('com.google.firebase:firebase-bom:27.0.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
```

Finally sync!

**`Now celebrate as you've just finished setting up Firebase and the true fun can start ✨✨`**
