In Android Studio, Log In With Google Using Firebase Authentication

Do you wish to create your users fall dotty together with your app by building a seamless married woman victimization base of operations and a Google account? If that is the case, continue reading.

I don't suppose I would like to mention however exacting fashionable users have become: they require the most effective smartphone, internet, and dish delivery.

Signup with Google

You may be questioning what is wrong with requesting sensitive details like username, 1st and name, and Arcanum.

The issue is that users became addicted to apps that modify them to check in with Google instantly.

Furthermore, so as to be effective at one thing, you want to perceive one basic law. you want to continue with the simplest competitors on the earth.

What does it mean?

It means that you’ll ought to follow constant standards, frameworks, and techniques that the simplest competitors implement in their apps since they’ve employed the simplest oscilloscope, ASO and employee specialists.

The feature's TL;DR is that it:

  • This saves time for each the developers and therefore the finish users.
  • Gets all the knowledge you wish, like your name and email address.

How Does It Work?

More than a billion individuals have already connected their Google accounts to Google Play. When the Associate in Nursing app has been verified and has received all of the mandatory info from Google Play, it's able to use.

If a user is not already signed in to Google Play, they will have to be compelled to do thus so as to relish the sport, that is unlikely to happen.

Steps to Login with Google in Android Studio Using Firebase

In Android Studio, create a new project.

In Android Studio, create a new project. How? You need to tap on File -> New -> New Projects.

create new project

Tap on Empty Activity -> Next

Empty Activity

Give Name to New Project -> and Click Next

Name

Steps to Add Firebase into an Android Project

Firebase should be added to your project.

by clicking on Tools -> Firebase

opening Firebase Assistant

As seen within the image below, base Assistant is currently open on the correct aspect, and you'll go on Email and word Authentication.

Authentication

Now select Connect to Firebase from the drop-down menu.

Connect to Firebase

If you're not signed in to robot Studio, a window can seem in your browser asking you to register to your Google account.

Login Console

Then click Next.

Login Console next

You are currently work in to mechanical man Studio, associated an email is shipped to your machine from Google oral communication, "You've signed in with mechanical man Studio."

Login console success

When you open mechanical man Studio, you will see a popup box like the one below. If you wish to alter the project name, choose the state, so click hook up with base.

New Firebase project


If you see a inexperienced color text Connected on the lowest right aspect of the screen, you are sensible to travel. to feature base of operations Authentication to your app, press Add base of operations Authentication to your app.

add Firebase Authentication To App

Now press settle for Changes within the popup box that seems. this can add sure app-level and project-level dependencies to your project.

Accept Changes

Now you can see dependencies set up correctly.

Dependencies setup correctly

Now open https://console.firebase.google.com/ and Sign in with an equivalent account you accustomed check in for automaton Studio. As you'll be able to see, your plan has been b at now. Click on it.

open project In console

Now Press on Authentication Tab -> Sign-In method -> Press Google Button -> Enable Toggle button -> Select Email Address.

Enable Google authentication

Presson Save Button.

Authentication save


Now open Android Studio and then press on Select Android -> Gradle Script -> Open build.Gradle file

Now press Sync Now after adding these two dependencies.

implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

Add dependencies


Building UI

Before we tend to begin building the interface and begin cryptography the practicality, we want to feature net permission within the robot Manifest file. i'm doing it at the terribly starting as a result of I usually forget to feature it then begin scratching my head that why the code isn't working!

Add Internet permission in AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>

Add permission

Enter code in activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
 
    <com.google.android.gms.common.SignInButton1
        android:id="@+id/SignIn_Button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="284dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
 
    <Button
        android:id="@+id/Sign_out"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="sing out"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/SignIn_Button"
        app:layout_constraintVertical_bias="0.258" />
 
</androidx.constraintlayout.widget.ConstraintLayout>

Post a Comment

Previous Post Next Post