Here the steps required to create a Firebase project and to connect it with an Android app.
Create a Firebase project in the Firebase console and click Create New Project.
Click Add Firebase to your Android app and follow the setup steps.
When prompted, enter your app's package name.
It's important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.
At the end, you'll download a google-services.json
file. You can download this file again at any time. ( this file is located under project setting in Firebase console).
Switch android studio View to Project and paste google-service.json file under app folder
The next step is to Add the SDK to integrate the Firebase libraries in the project.
To integrate the Firebase libraries into one of your own projects, you need to perform a few basic tasks to prepare your Android Studio project. You may have already done this as part of adding Firebase to your app.
build.gradle
file, to include the google-services plugin:buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.1'
}
}
Then, in your module Gradle file (usually the app/build.gradle
), add the apply plugin line at the bottom of the file to enable the Gradle plugin:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.4.0'//THIS IS FOR ANALYTICS
compile "com.google.firebase:firebase-database:11.0.2"
}
// BELOW STATEMENT MUST BE WRITTEN IN BOTTOM
apply plugin: 'com.google.gms.google-services'
Notes:
Data cannot be read/write without Authenticating. If you want it without authentication. Change rules in Database firebase console.
{ "rules": { ".read": true, ".write": true } }
Add internet permission in Manifest
Upgrade Google Play Services and Google Repository