Firebase is a mobile platform which provides various facilities like authentication, real time database, storage to build a professional app in no time. All these features are very important for modern mobile application specially those which require user accounts. So if you are new to Firebase and wanted to get started with it then you have come to right place.
In this article, I am going to show you how to add Firebase to android project in Android Studio. First thing that we need to do is open our android Project in Android Studio if already created or create a new project. While project is loading, open Firebase Console in your browser. If you are not logged in your browser with google account then you will be prompted to login first.
Coming back to Android Studio, here we need to connect our Android studio to our google account. On right top corner below the exit, you will see option “Sign in to Google…”. Click on this button and then click on “Sign in”.
Once again you will be prompted to sign into your google account in browser. After signing into your google account, you need to “Allow” access to Android Studio.
Come back to Firebase Console and follow three simple steps to create your first Firebase project.
- Click on “Create a Project”.
- Give a name to your project (need not to be same as project name in Android Studio). Accept Firebase terms and click “Next”.
- Next you are asked if you want to add Google Analytics to your project. Enabling Google Analytics provides you features like A/B testing, Event-based Cloud functions trigger and many more. Once decided you can click next to finish the setup.
You will be directed to your project on Firebase.
Now you are ready to add your app to Firebase. Click on Android icon and register your app by writing your android package name in provided field. Android package name is in the form “com.example.<project_name>” if you haven’t changed domain while creating project. See image below to see where you can find package name.
After writing package name, you can skip other fields empty and click on Register App. Next download google-services.json file from the link provided and go back to Android Studio. Here you need to switch to Project view.
Now copy the downloaded json file and paste it “app” directory of your project.
Back in Firebase console, click on Next. This is very important step, here you need to modify the gradle file in order to use google services plugin which you just moved to your project.
Carefully make changes in respective gradle files as mentioned in “Add Firebase SDK” step. Once you paste required text, click on “Sync Now” on Android Studio.
After syncing is complete, you can click Next and that is it. You are now ready to use different Firebase feature which can enhance your app to professional level.
Thanks for reading ! If you are interested in adding Firebase tools to your android project, you can check out my article on Adding Firebase Authentication to Android Project .