I’ve written quite a few blog posts about Firebase lately. That’s because I think that Firebase is an essential tool that a self employed Android developer must have. As a single person, it can get overwhelming evan just thinking about the amount of work that you must put in in order for your app to work. Adding a backend server to your app can really breath fresh air into your app. Firebase is can be immensely useful, even if you’re going to use only the Analytics part of it. If you don’t know what Firebase is and what features does it bring to the table, then check out this blog post that I wrote about learning what Firebase is.
In order that your app runs on the device, the device must have Android 4.0 (Ice Cream Sandwich) or higher and Google Play Services 11.0.2 or higher.
Android Studio must be version 1.5 or newer. And you need to have the newest version of the Google Repository.
Create a Firebase project
Before adding any code into your app, first you need to create a Firebase project. I order to do that, you need to have a Google account.
To create a Firebase project, go to the Firebase Console. From there, you can import a Google project, or create a new Firebase project.
As you may already know, if you’ve read the blog post about the Firebase features, Firebase can be integrated into an Android app, iOS app, Web app, Unity app, and C++. Since this is a blog about Android development, we’re going to focus on how to add Firebase to your project.
After you create the Firebase project, you can choose to which platform you want to add Firebase. Choose Android. A new popup will show up. This popup requires you to enter your app’s package name, an optional nickname for the app and an optional SHA-1 debug signing certificate (to see how to get this value go to this page).
You should get a link to download the google-services.json file. You must put this file in the app folder of your Android Studio project. You can do this directly through Android Studio. This file contains important information which allow your app to integrate Firebase. The file contains things like your API key, Firebase project name, etc.
If you’ve done all of this, you should now see the Firebase console. From here, you can access all of the features of the Firebase SDK. I will cover each one of them in depth in the future (currently I have only covered a part of the Real Time database, and you can check that out here
Add the SDK in the Gradle
Add this to your build.gradle:
Be sure to check is the version of the google services is correct.
Now add this to your module Gradle file. You will add all the other Firebase SDKs in this file. The firebase-core only gets you access to the Analytics part of the Firebase SDK.
To add other Firebase features just simply compile them like you did the firebase-core. To check the current newest version of the Firebase libraries to here.
Now you can go build your Firebase enabled app. These ten minutes that it took you to create a Firebase project and to integrate Firebase into you Android app will save you A LOT of time. Not only time, but money as well. To create your own back end server, you need to rent a REAL server, unless you’re going to host it on your old PC in your bedroom. Not saying that building your own server is now good. If you want to be a backend developer or a devops than 100%, go and build a server out of your old PC and host your backend database for your Android app on it.