Register using email and password – Firebase – Android


Hi guys, it’s been a long time since I have shared any new article on android. I was busy doing an android project. Here you can find the project which I made. Google’s firebase plays a vital role in this app. All the backend work in this app is done using firebase. And honestly, I have learnt a lot from this project. So thought of sharing some knowledge with you.

So in this article, we are going to see how the registration process is done using email and password.

Register using E-mail and password – Firebase

First of all, create a new project in Android Studio and name it My Firebase Authentication.

Now go to Firebase and go to console and Add a new project.


The project overview page will open. There are three options to choose from. Add Firebase to your iOS app, Add Firebase to your Android app and Add Firebase to your web app. Select Add Firebase to your Android app, as we are creating an Android project here.

You will see a pop up where you have to enter your Android package name, app nickname and SHA-1 fingerprint. The app nickname and SHA-1 are optional. But we will add all three.

Enter your Android package name. Get the package name from your project AndroidManifest file. Give any nickname you want (If you want to). And enter the SHA-1 fingerprint.

Get the SHA-1 fingerprint – 


Now click Register app. The Google-services.json file will be generated for your project. Download the json file and copy it.

Go to Android Studio and switch to project view. Right click on app and paste the file.


Next, click on continue and add the dependencies to your Project-level build.gradle and App-level build.gradle. Now that we have added firebase to our project, we can start doing the authentication part of our project.

On the left side of your Overview window, there is an option Authentication. Click on that.

Click ‘SETUP SIGN_IN METHOD‘ and enable Email/Password. That’s all the work we need to do here.

Now go to your project manifest file and add internet permission.

Also, we have to add –

As we are doing authentication here.

After adding the permission, let’s design the layout of our registration activity.

I am making the layout as simple as possible. There will be only two EditTexts, for the email and the password. And a Button to register. I am also not doing any validation.

But you should always do that. Make two EditTexts for email and re-type email. Two EditTexts for password and re-type password. Also, don’t forget to validate the email.

Note – The length of the password should be minimum 6.

This is my simple layout of MainActivity.

Now let’s jump to the coding part.

To register with email and password, first, we need to initialize a FirebaseAuth instance and to create an account there is a method createUserWithEmailAndPassword(). This method takes to parameters, email and password.

createUserWithEmailAndPassword(String email, String password);

Below is the code of our updated

This will register the user with entered email and password. A unique UID will be generated for each user. We don’t need the UID right now.

Firebase also provides an on completion callback method .addOnCompleteListener() to know if the registration was successful or not. We will show a toast message if the registration is successful. Update your to match ours.

That’s all. Let’s run the project.

Enter email and password. Hit the register button. If everything is good you will see the ‘Registration successful’ message.

To confirm the registration, go to your firebase console. Navigate to Authentication and then users. There you will see the details of the newly created account.

Hope you understood how the firebase registration is done. If you have any doubt or query please do comment below in the comment section.


You May Also Like


Leave a Reply

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