Introduction
Gmail Login is an easy way for users to log in. Gmail Login automatically retrieves all the user information.
Let’s start!
Before starting our Android application creation, we need to create a Gmail Developer account's new application and enable Google API.
Step 1
Go to API Console from https://console.developers.google.com/apis/dashboard. Check the page on the left side corner and go to Project Name Dropdown. Now, click the + button which opens one more window for app creation. It asks for Project Name, followed by clicking "Create" button. Finally, move to dashboard.

Step 2
Next, we need to enable API for Google+API. Go to API Library ->Social APIs->Google API. When it is clicked, it enables the API button. Then, click to enable.


Step 3
Afterwards, select OAuth then platform for an Android, followed by giving the Name, Package name, Key Hashes [Create Key Link].



Step 4
Open Visual Studio->New Project->Templates->Visual C#->Android->Blank App. Now, give the Project Name and Project Location.

Step 5
Now, go to Solution Explorer-> Project Name-> References. Right-click to "Manage NuGet Packages", followed by opening a new dialog box. This dialog box helps to search Google Plus, followed by installing Xamarin.GooglePlayServices.Plus Packages.

Step 6
Go to Solution Explorer-> Project Name-> References, right-click to get more components which opens a new dialog box. This dialog box is required to search the AppCompat, add the Xamarin.Android.Support.v7.AppCompat Library Packages.

Step 7
Open Solution Explorer-> Project Name->Resources->layout->Main.axml. Click "Open Design View".
AXML code
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
- <com.google.android.gms.common.SignInButton android:id="@+id/sign_in_button" android:layout_width="match_parent" android:layout_marginTop="10dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginBottom="30dp" android:layout_height="wrap_content" />
- <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/sign_in_button" android:id="@+id/relativeLayout1" android:layout_marginLeft="20dp">
- <TextView android:text="Name : " android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView1" />
- <TextView android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/textView1" android:id="@+id/TxtName" android:layout_marginLeft="10dp" /> </RelativeLayout>
- <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/relativeLayout1" android:id="@+id/relativeLayout2" android:layout_marginLeft="20dp" android:layout_marginTop="10dp">
- <TextView android:text="Gender : " android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView2" />
- <TextView android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/textView2" android:id="@+id/TxtGender" />
- </RelativeLayout>
- <ImageView android:src="@android:drawable/ic_menu_gallery" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/relativeLayout2" android:id="@+id/ImgProfile" android:layout_centerInParent="true" android:layout_marginTop="50dp" />
- </RelativeLayout>
Step 8
Now, open Solution Explorer-> Project Name->MainActivity.cs. Click Open CS code page view, followed by adding the namespaces given below.
- using Android.Gms.Common.Apis;
- using Android.Gms.Common;
- using Android.Gms.Plus;
- using Android.Util;
- using Android.Graphics;
- using System.Net;
Step 9
Add public class MainActivity: GoogleApiClient.IConnectionCallbacks, GoogleApiClient.IOnConnectionFailedListener Interface.
Step 10
Create new variables followed by assigning all the variables values.

C# code

Aniqa RaoufPosted Oct 16, 2020, 10:05 AM
I want Gmail Api ...its Not Working for that
Peter MagedPosted Apr 8, 2020, 4:47 PM
Where the client id that get it from google developer application
Peter MagedPosted Apr 8, 2020, 4:46 PM
How to get Google Play Services version
Peter MagedPosted Apr 8, 2020, 4:46 PM
I did all of these steps but its always disconnected
davePosted May 24, 2019, 10:06 AM
Hi Anbu, Great tutorial and thank you. I am however not getting where the information in Step 3 is used in the Android project code. Does that mean that setting up the credential is enough for the app? Doesn't the app need some sort of info (such as UriScheme) to send back, and if so where is that used? How do you get the numeric value for google_play_services_version? How do you hide the visual object created by SetContentView()?
Aousaf rashidPosted May 9, 2019, 4:05 PM
Where is `PlusClass` defined?
Mohanasundharam MuruganPosted May 8, 2019, 4:58 AM
How to signout the account?
KALYANI SHINDEPosted Dec 26, 2018, 11:34 PM
I dont understand all step 10 which file where included
Valle SureshPosted Oct 22, 2018, 1:22 PM
After login resultCode getting as cancel. what was the issue?
Juan SamanoPosted Sep 9, 2018, 1:56 PM
Hello Anbu, congrats by your effort with this tutorial. If im using Xamarin Forms it would work in the droid project?
Bjorn LizaPosted Mar 28, 2018, 8:50 AM
Isn't Google Plus Api deprecated?
radhika ramineniPosted Feb 27, 2018, 1:27 PM
How to get package name and SHA-1
Vidyadharran GPosted Feb 25, 2018, 11:06 AM
Cool thanks for sharing bro!!!!!....
Sagar Pandurang KapPosted Feb 23, 2018, 4:36 AM
Great work .kkep sharing...
Gajendra JangidPosted Feb 23, 2018, 3:15 AM
Vary nice article.........................................