Android – Getting Started with Firebase – 1

In this tutorial we will learn about Firebase from Google I/O. To learn about Firebase, here we will create a login and registration page using Firebase Email & Password Authentication. Firebase is introduced with bunch of features for our android app starting from authentication to hosting our app.

1. Enabling Firebase Auth

  • First of all we will go to and make an Firebase account to gain access to their console.
  • Click on “GET STARTED FOR FREE” on that page to create account.
  • Login through your Gmail Account. After login you will be redirected to the Firebase Console.
  • Now on the console page click on “CREATE NEW PROJECT“.
  • Fill the Project name and select the Country and click on CREATE PROJECT. Here I am taking Project name as “Authentication” and Country as “India“.
  • Now click on “Add Firebase to your Android App” on your console screen.
  • Fill the “Package Name” and leave “Debug signing certificate SHA-1” as blank and click on “ADD APP“. Here I am taking package name as “net.apptronix.www.firebase_authentication“. Here the google-services.json file will be downloaded when you press Add App button.
  • After this click on “Continue” and “Finish“.
  • Now on the project dashboard click on the “Auth” on left hand side and click “Set Up Sign-In Method” and choose Email & Password and enable it and then click on Save.
  • Now we are all set to create our Android Project. In this app we will use Firebase Authentication in which we will learn to  to add Login, Registration, Forgot Password, Change Email, Change Password & Sign Out option.

2. Creating Android Project

  • Create a new project in Android Studio from File ⇒ New ⇒ New Project. Give the Application Name and Package Name. While giving Package name, give the same package name that we have given during the Firebase Console. For me its net.apptronix.www.firebase_authentication
  • Select Blank Activity when it asks you to set default activity and proceed and lastly click on Finish.
  • Now open AndroidManifest.xml that is inside manifest folder on the left and add the INTERNET permission as we have to use internet in our app.

  • Paste the google-services.json file that we have downloaded previously to our project’s app folder. This step is very important as your project won’t build without this file.
  • Now open the build.gradle located in project’s home directory and add firebase dependency. We have to build.gradle file, one is in the project’s home directory and other is in the app folder. So we have to add dependencies on the file in the home directory.

  • Open app/build.gradle and add firebase auth dependency and at the very bottom of the file, add apply plugin: ‘’. We have to open build.gradle file which is inside the app folder.

  • Click on Sync Now that must be coming on top right corner.
  • Now we will make some activities :
    • SignUpActivity
    • LoginActivity
    • ResetPasswordActivity
    • & MainActivity will be our Profile Activity that we will get after logging in.
  • Right click on app folder go to New ⇒ Activity ⇒ Empty Activity
  • Give the Activity Name as “SignUpActivity” and leave all thing as default and click on Finish.
  • Similarly make two more activities named LoginActivity & ResetPasswordActivity.

2.1 Sign Up with Email & Password

  • In this activity we will take two EditText fields for Email & Password, & three buttons for Register and navigating to Login & Forgot Password activity.
  • Go to res ⇒ layout ⇒ activity_sign_up.xml and paste the following code there.

  • Now Go to file and paste the following code just below the package line. Here we will use createUserWithEmailAndPassword() provided by Firebase, a method to create a new user with email and password.

  • Lastly open AndroidManifest.xml file and make SignUpActivity as launcher activity (for now) and test the sign up process.

  • Ok now run the app and check either your SignUpActivity is working or not. You will get the following output.
  • After SignUp, login to your Firebase account again and go to the Firebase Console and click on Auth. Here you will see that user is successfully registered with desired email and password that you have provided in the app.
  • Congrats !! Now we can create user with email and password in Firebase.
  • Now we will learn about LoginActivity, ResetPasswordActivity and MainActivity in our next tutorial. Thank you for visiting this tutorial. If you have any doubts or queries regarding this, you can comment below in our comment section. Please check our next part for remaining part of this tutorial.

Next Part : Android – Getting Started with Firebase – 2

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *