Android Firebase Tutorial – User Registration with Authentication

Hello friends, in this Android Firebase Tutorial, we will see how we can make User Registration in Android by using Firebase as our App’s backend. I have already posted an Android Firebase Tutorial. But firebase is now taken by …

android firebase tutorial

Hello friends, in this Android Firebase Tutorial, we will see how we can make User Registration in Android by using Firebase as our App’s backend. I have already posted an Android Firebase Tutorial.

But firebase is now taken by google and things are changed a little. That is why I am again posting this Android Firebase Tutorial. Today we will learn about making User Registration using Firebase Authentication for Android. If you are interested in Swift and iOS then you can go through this Firebase iOS Tutorial.

What is Firebase?

Firebase is a cloud service provider. It is now under google and this service can replace your whole server side part of your application. In many tutorials we had used MySQL and PHP for our database. But if we will use Firebase we do not need any server side code or configuration. We can directly use firebase. Firebase comes with a bundle of many features.

Features of Firebase?

firebase features

Android Firebase Tutorial – Video

You can keep on reading this tutorial but if you don’t want reading, you can watch this video. This is not like my other videos. This is a complete explanation of this post. So you can go through this video as well.

Android Firebase Tutorial

So without wasting time lets start our Android Firebase Tutorial. We will start from creating a new project.

From this tutorial you will see screenshots of OS X. 😛 Thanks to you guys, I managed to get MacbookAir with your support. 🙂

Creating an Android Studio Project

  • Open Android Studio and Create a New Project. I created FirebaseAuthDemo.
  • Now wait for your project, once it is fully loaded we can start working.
  • But before we need a app in Firebase Console as well. So switch to your browser from Android Studio.

Adding Firebase to our Project

getting started with firebase

  • Now click on create a new project. create a new project
  • Give your app a name and click on create project.

create a project

  • Now you will see the Firebase Panel. You need to click on Android Icon here.

firebase android tutorial

  • Now you will see a panel here you need to put the package name of your project. You can get the package name from AndroidManifest.xml file. Copy the package name and paste it here and then click on Add App.

firebase android tutorial adding app

  • When you click Add App, a file named google-services.json will be downloaded. You need to paste this file inside app directory of your project. See the below image for explanation.

firebase android tutorial adding googleservices

  • Now come inside your project level build.gradle file and modify it as follows.

  • Now modify your app level build.gradle file as follows.

  • Now sync your project with Gradle.

Adding Firebase Authentication

As in this Android Firebase Tutorial, we are building a user registration application, we need to use Firebase Authentication. So we need to add Firebase Authentication to our project. For this go inside app level build.gradle file and inside dependencies block add the following line.

Again sync your project.

Enabling Email/Password Authentication

  • Again go to your firebase panel.
  • On the left side menu you will see Auth, click on it.

firebase android tutorial enable auth

  • Now click on Set Up Sign In Method.

set up signin method

  •  Now click on Email/Password, enable it and press save.

firebase android tutorial user reg

Creating User Signup Form

  • Now we will need to create a form in our activity from where user can Sign Up to our app.
  • Come inside your Android Studio Project, and in activity_main.xml write the following code.

  • The above code will generate the following UI.

Firebase Android Tutorial

Understanding Firebase Signup

This is the main part of this Android Firebase Tutorial. First I will tell you about the methods. As we will be using Firebase Authentication for the user Signup we need these steps to get it done.

Step #1

First we will define a FirebaseAuth object. Then inside method onCreate() we will initialize this object. See the following code snippet.

Step #2

Now we will call the method createUserWithEmailAndPassword() from the FirebaseAuth object. This method take two String parameters for email and password. And we attach a OnCompleteListener on it to check the task is completed or not.

Implementing Firebase Signup

We understood the code. Now lets implement it to make registration work in the activity. Write the following code in your MainActivity.java

  • Now lastly add internet permission to your AndroidManifest.xml file.

  • Now run your application. firebase android tutorial
  • Click on Signup and if you got the success message. Check your firebase console.

firebase android tutorial register user

  • Bingo! the registration is working fine. You can get my source code from the link below.

[sociallocker id=1372] [download id=”3114″] [/sociallocker]

So thats all for this Android Firebase Tutorial friends. In the next post we will see about user login and other options like Password Reset, Email Change, Delete Account etc.

And yes feel free to leave your comments if having any confusions regarding this Android Firebase Tutorial. Thank You 🙂

Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.

Expand Your Knowledge: Next Tutorial Picks

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x