Creating a Firebase Project and connecting it to an App
NOTE: This article is over 2 years old, you can read this as a reference only, the code snippets might be outdated
First of all, you need to have a Google Account to create a Firebase Project. If you don’t you can create one here. After creating Google Account you need to create a Firebase Project here, now follow the following simple steps.
Step 1: Name Your Firebase Project
Read, and Accept the Firebase Terms, if you agree.
Step 2: Google Analytics Opt-in/out
Opting-in to Google Analytics is Optional but if you decide to opt-in you get, in debt analytics and some demanding features, free, from Google. if you opt-in here you will have another step otherwise this will be your final step.
Step 3(Final Step): Location and Sharing
Select your Location for Analytics, and you can choose what data to collect/share via Google Analytics. After choosing carefully what data to share and what to not, read the following terms and conditions, accept if agree, and Create your Project.
Creating Project will take some time. So sit Tight! once the project is ready you’ll be prompted hit Continue.
Select your Platform i.e Android/iOS/Web or Unity (I’ll go with Android for now)
Step 1:
Enter your Package name, if you don’t know what it is you can always check it here in default package name is com.example.[your_app_name]
[project] > android > build.gradle {here you can find it as applicationID in `defaultConfig` bloc}
you can also add a nickname for your Application(merely for distinguishing if you have more than one app)
SHA keys are for user authentication, we don’t need them in this scenario, but if you still want to add them, here’s how
keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
Just copy, paste and run this in your terminal
Step 2:
Download the following config File, and paste them in the following directory.
[Project] > android > app
Hit next after doing this.
Step 3:
For the following step, I would strongly recommend using Android Studio.
Open the following two files
Add the highlighted line of codes in the build.gradle(Project: android) file
Add the highlighted line of codes in the build.gradle(Module: app) file
if you had opted-in for Google Analytics, you have to add this line as well, otherwise, you don’t have to:
After adding all the above line of codes, you have to now, sync the project for building the gradle. If you encounter an error about gradle, check this video, it might help
After Gradle builds and the app synced, we have connected our app to FIrebase. Now, if you had opted-in for Google Analytics, you should now run the app to verify the connection with Google servers.