Google+ sign-in lets users sign in to your Android app with their existing Google account and get their profile information like name, email, profile pic and other details. By integrating google plus login in your apps, you can get all the user details in one shot. Not only login, you can do other things like posting to their g+ account, getting list of circles, friends list and lot more. The major advantage of integrating G+ login is, you can drive more users to your app by providing quicker & easiest way of registration process.

android login with google plus account

So let’s start by doing required setup.

1. Installing / updating Google Play Services

Google plus is a part of Google Play Services API. So first we need to download the google play services in Android SDK manager. If you have already installed play services, it it very important to update it to latest version. Open the SDK manager and install or update the play services under Extras section.

android sdk manager installing play services

2. Generating Google-Services.json

Now all the android projects which uses google apis, requires google-services.json file to be placed in project’s app folder. Follow the below steps to get your google-services.json file.

2.1 Java keytool can be used to generate SHA-1 fingerprint. Open your terminal and execute the following command to generate SHA-1 fingerprint. If it ask for password, type android and press enter.

On windows

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

On Linux or Mac OS

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

In the output you can notice SHA1 fingerprint.

android generating sha1 fingerprint

2.2 Goto android quick start guide and click on Get A Configuration File button. This will redirect you to a page where you can choose the project and package name.

2.3 Create / choose an app and give your current app package name. I gave my package name as info.androidhive.gpluslogin.

2.4 Paste the SHA-1 fingerprint and click on Enable Google Sign-In. Finally click on Generate Configuration File to download your google-services.json


3. Creating New Project

3.1. Create a new project in Android Studio from File ⇒ New Project. When it prompts you to select the default activity, select Blank Activity and proceed.

While filling the project details, use the same package name which you gave in google console. In my case I am using same info.androidhive.gpluslogin

3.2. Open project level build.gradle and add ‘’ class path to dependencies.

dependencies {
        classpath ''
        classpath ''

3.3. Open app level build.gradle and add ‘compile’ to dependencies. At the bottom of the file, add apply plugin: ‘’

You can notice that, Glide dependency also added here to load the google profile picture in image view. This is completely optional.

dependencies {
    // ..
    compile ''

    // glide is added to load the g+ profile image. Ignore if you want
    compile 'com.github.bumptech.glide:glide:3.7.0'

apply plugin: ''

3.4 Open strings.xml file located under res ⇒ values and add following strings.

<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">G+ Login</string>
    <string name="action_settings">Settings</string>
    <!-- Button text -->
    <string name="btn_logout_from_google">Logout from Google</string>
    <string name="btn_revoke_access">Revoke Access</string>

3.5. Now I am designing a simple layout to display user’s profile picture, name, email and other buttons. Paste the below code in layout file of your main activity. In my case my layout file name is activity_main.xml

<LinearLayout xmlns:android=""
    tools:context=".MainActivity" >



            android:layout_weight="2" >

                android:textSize="20dp" />

                android:textSize="18dp" />



        android:visibility="gone" />


3.6 . Now open and do the below modifications. The code is self explanatory and very easy understand.

> implement the activity from GoogleApiClient.OnConnectionFailedListener

> Create the GoogleApiClient instance in onCrate() method.

> signIn() performs google plus sign in, signOut() logs out user from google account and revokeAccess() completely revokes the access from google plus.

> onActivityResult() is called whenever user returns from Google Login UI.

> In onStart() method, checked for cached google sign in session and appropriate UI is displayed.

> handleSignInResult() handles the google plus profile information upon successful login.

> updateUI() toggles the UI by showing / hiding the appropriate buttons and text views.

package info.androidhive.gpluslogin;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

public class MainActivity extends AppCompatActivity implements
        GoogleApiClient.OnConnectionFailedListener {

    private static final String TAG = MainActivity.class.getSimpleName();
    private static final int RC_SIGN_IN = 007;

    private GoogleApiClient mGoogleApiClient;
    private ProgressDialog mProgressDialog;

    private SignInButton btnSignIn;
    private Button btnSignOut, btnRevokeAccess;
    private LinearLayout llProfileLayout;
    private ImageView imgProfilePic;
    private TextView txtName, txtEmail;

    protected void onCreate(Bundle savedInstanceState) {

        btnSignIn = (SignInButton) findViewById(;
        btnSignOut = (Button) findViewById(;
        btnRevokeAccess = (Button) findViewById(;
        llProfileLayout = (LinearLayout) findViewById(;
        imgProfilePic = (ImageView) findViewById(;
        txtName = (TextView) findViewById(;
        txtEmail = (TextView) findViewById(;


        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)

        // Customizing G+ button

    private void signIn() {
        Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
        startActivityForResult(signInIntent, RC_SIGN_IN);

    private void signOut() {
                new ResultCallback<Status>() {
                    public void onResult(Status status) {

    private void revokeAccess() {
                new ResultCallback<Status>() {
                    public void onResult(Status status) {

    private void handleSignInResult(GoogleSignInResult result) {
        Log.d(TAG, "handleSignInResult:" + result.isSuccess());
        if (result.isSuccess()) {
            // Signed in successfully, show authenticated UI.
            GoogleSignInAccount acct = result.getSignInAccount();

            Log.e(TAG, "display name: " + acct.getDisplayName());

            String personName = acct.getDisplayName();
            String personPhotoUrl = acct.getPhotoUrl().toString();
            String email = acct.getEmail();

            Log.e(TAG, "Name: " + personName + ", email: " + email
                    + ", Image: " + personPhotoUrl);


        } else {
            // Signed out, show unauthenticated UI.

    public void onClick(View v) {
        int id = v.getId();

        switch (id) {



    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);

    public void onStart() {

        OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
        if (opr.isDone()) {
            // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
            // and the GoogleSignInResult will be available instantly.
            Log.d(TAG, "Got cached sign-in");
            GoogleSignInResult result = opr.get();
        } else {
            // If the user has not previously signed in on this device or the sign-in has expired,
            // this asynchronous branch will attempt to sign in the user silently.  Cross-device
            // single sign-on will occur in this branch.
            opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                public void onResult(GoogleSignInResult googleSignInResult) {

    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
        // An unresolvable error has occurred and Google APIs (including Sign-In) will not
        // be available.
        Log.d(TAG, "onConnectionFailed:" + connectionResult);

    private void showProgressDialog() {
        if (mProgressDialog == null) {
            mProgressDialog = new ProgressDialog(this);

    private void hideProgressDialog() {
        if (mProgressDialog != null && mProgressDialog.isShowing()) {

    private void updateUI(boolean isSignedIn) {
        if (isSignedIn) {
        } else {

5. Testing the app

On Real Device:
You can directly test this app on a real devices which is having Google account connected.

On Emulator:
You can also test the application on an emulator which runs Android 4.2.2 or greater. Follow below link to know how to configure an emulator by installing Google Play Services.
Configuring emulator with Google Play Services

If user clicks on sign in button, the following popup will be shown asking user to sign-in using google plus account.

Change Log

Updated On 2nd Sep 2016 (Content Update, Bug fixes)
Ravi is hardcore Android programmer and Android programming has been his passion since he compiled his first hello-world program. Solving real problems of Android developers through tutorials has always been interesting part for him.
  • Nicolas


    Very good tutorial, as always !
    Thank’s from France !

    • You are welcome 🙂

      • Cristiana

        Hi Ravi do you have sample apk for this toturial ? i have error , i am using android studio.

  • Jeffy Lazar

    This blog is awesome and
    This guy “RAVI TAMADA “is a super helpful genius

    Thanks alot man for your hardwork shown in this great tutorials
    really helps alot 🙂 🙂

  • Vaibhav

    not getting the meta data value in manifest @integer/google_play_services_version

    • Make sure that you updated Play Services to latest version and import the library again.

      • Vaibhav

        I am using the latest version of play services i.e. 15 but not getting option @integer to add.. i am using app version 10…is this an issue..?

        • No app version won’t be an issue. Please open SDK manager and re check again. Why because I got the same problem.

          • Vaibhav

            @ravi8x:disqus thnks ..i have deleted my google play lib and download and install it again.. i got the option.. thanks for your help..

          • gie


        • Leonardo Lopes

          I Know how to solve this issue. At eclipse IDE you need dont paste the lib at lib folder. At Package explorer make a right click on mouse and select import projects, already existent android project and select folder that contains your google play services.

          After that, a new project called same name of the library will appear.

          Next step, is make this project as a library.

          Click right button on the new project and select properties. check options is a library.

          Now is all ready to use this library, in your project go to the properties, and in list of library’s right down the check “is a library” click at “add” and select google play project.

          I Hope help you.

          More information can be founded at:

          Best regards


  • Ranjit Paul

    Getting error on Plus field

  • Pavlos

    Keep up the great work mate!! Congrats!

  • Sushil

    I want to integrate it into my app .. but every time i try to start the Activity containing G+ Login the app crashes .. The other activities work fine

  • Dave

    Hi, I have problem, I pushed sign in button, then I pick my account from the list, and then I received something like: “Internal error”. Can you help me?

  • mina mohsen

    iam getting this error in the xml file:-
    The following classes could not be instantiated:

    and the button is not seen

    • Andrew

      The Google Plus library hasn’t been added as a library then.

      • mina mohsen

        this is only in the design page only , the java classes work normly ??

        • Andrew

          Try cleaning your project. I was able to implement the button in a similar solution inside android studio (refresh gradle if you are using that). Also check for any kind of typo or parameter that doesn’t go with that view. For some reason I type amdroid: instead of android: a lot.

  • Craig

    Thanks mate,
    Small note, if you’ve a project created with the old console, it won’t have a project id, this will cause you to get an ‘internal error has occured’ toast when trying to sign in. You need to create a new API project and specify a project id, and create the auth id there (if you’ve already added one to your old project, delete it first).

    • Anil Chahal

      Thank you so much dear .. i was facing this problem, and i did what you just written above.. Good observation .. Thanks again. 🙂

    • wladimir

      Hi, Can you tell more precisely where to add project Id, and how to use it in code?

  • Connie Leung

    Is it possible design camera app that takes picture and then upload to G+ account? Please advise. Thanks.

  • Anil Chahal

    Great work Ravi. Keep it up .. This blog is simply rocking man. Congrts.

  • Kumar

    Good work Ravi..Nice blog for android community

  • Once again a very simple and easy to understand tut.

    Thanks very much! Your a great help


  • Great tutorial,

    how ever do i have to run this on an a real device because i get update google play services when i run?

    • worked after updating google play services, awesome tutorial again

  • Phuc Nguyen

    Great article! Thanks so much

  • Hasnain Ali

    when I run on real device got “An internal error occur”

  • Rami

    I got “An internal error occur”

    • Sumit Ingewar

      Please check that you have registered right package name on API Console

  • Vihang

    I got “An internal error occur” what can i do solve this error. .

  • Riyas V

    Great tutorial man, Thank you very much.

  • Tugsbayar

    Hi. Is it possible to log in by custom email of google. For example: i have When i log in program let me download things. When i log in by other email such as i can not download things.

  • Guest

    03-02 09:56:23.745: E/AndroidRuntime(1536): FATAL EXCEPTION: main

    03-02 09:56:23.745: E/AndroidRuntime(1536): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.gpluslogin/info.androidhive.gpluslogin.MainActivity}: android.view.InflateException: Binary XML file line #47: Error inflating class

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at$600(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at$H.handleMessage(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.os.Handler.dispatchMessage(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.os.Looper.loop(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at java.lang.reflect.Method.invokeNative(Native Method)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at java.lang.reflect.Method.invoke(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at$

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at dalvik.system.NativeStart.main(Native Method)

    03-02 09:56:23.745: E/AndroidRuntime(1536): Caused by: android.view.InflateException: Binary XML file line #47: Error inflating class

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.createView(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.createViewFromTag(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.rInflate(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.inflate(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.inflate(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.inflate(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at info.androidhive.gpluslogin.MainActivity.onCreate(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): at

    03-02 09:56:23.745: E/AndroidRuntime(1536): … 11 more

    03-02 09:56:23.745: E/AndroidRuntime(1536): Caused by: java.lang.reflect.InvocationTargetException

    03-02 09:56:23.745: E/AndroidRuntime(1536): at java.lang.reflect.Constructor.constructNative(Native Method)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at java.lang.reflect.Constructor.newInstance(

    03-02 09:56:23.745: E/AndroidRuntime(1536): at android.view.LayoutInflater.createView(

    03-02 09:56:23.745: E/AndroidRuntime(1536): … 22 more

    03-02 09:56:23.745: E/AndroidRuntime(1536): Caused by: java.lang.NoClassDefFoundError:$drawable

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): at Source)

    03-02 09:56:23.745: E/AndroidRuntime(1536): … 25 more

    • ;)

      Check the Id od the buttons you have used..

  • Guest

    this part of source doesn’t work for me

  • ravi kiran

    This code works like charm but how to make sign out from different activity

  • Guest

    shi*!!! I did run this on api 17 bu not, this was my trouble, thanks for tutorial!

  • Mahesh kavathiya

    Hi Ravi thanks for your all tutorial i am always using your tutorial.but in this tutorial i have minor to change google+ icon. i mean can we set by default icon to our image or any icon instead of google+ icon.

  • Wa

    Thank you for the tutorial but I got an internal error.

  • Pinal Jakhar


    I am following this tutorial but getting the ‘internal error’ issue again and again.
    However, I had created android project using a different gmail account and my device is configured with different gmail account. Can this be the cause for this ‘internal error’ ?
    Do we need to add our android app’s Client Id somewhere?

    • Mahesh kavathiya

      please create your own application project in google developer console after run this project may be working perfact..but make sure package name will be same your project and google developer consol.

      • Pinal Jakhar

        I have created my application in the developer console, but with a different gmail account. But I think this tutorial is using the USE_CREDENTIALS permission to request the authtokens of the gmail account configured in the device. I want to use the gmail account for which I have developed the application. I want to know is there any way by which I can use the Client Id generated for my application

        • Mahesh kavathiya

          Yes pinal jakhar this tutorial only get device configured gmail can not use any other gmail account for this tutorial..

          • Pinal Jakhar

            I tried to find out how to do that with some other gmail account, but all in vain. I wonder if this Google Play Services sdk provides this option or not? There must be some provision for using other gmail account

    • thanks…

  • adu

    I have an error: cannot be resolved.

    • Abdul Wasi

      have you solve this problem? i have same issue

  • Mamro Kirill

    G + Returns age and a floor?

  • ram

    Thank you very much…

  • Shree

    Hi ravi,
    I had done exact setup as mentioned in your tutorial and but my device where i had deployed this app shows “internal error”, again and again.Can you tell us how to change package name or unique id created in google api console to run this project.
    If api and Package names are problem then what is way around to circumvent. I am using client side, desktop so it means that once keys are generated using same desktop will not be able to run this project.


  • Sushilkumar Yadav

    hie Ravi .. i need your help .. i have tried integrating G+ login in my app .. but it is throwing error ..”An Internal Error Occurred” .. Plz help it is my final year project ..

    • I solved the same problem adding in Google Developers Console the permissions also for Google+ Domains API and editing the Consent screen for my project. I hope that this can help you!

      • ramadon

        can u show me detail ? I got this problem too

      • Akhil chandran

        how to edit the Consent screen. please help

  • Gregory Galera

    Using google+ api on android, is it possible to allow a user to log in only on the first time they ever use the app, and from that point the app is always logged in auomatically, even after a device restart, and if so, can someone point me in the right direction?

  • Matthias

    I”m also getting the internal error when trying to sign in.

    • Tonyoh87

      same for me

      • Matthias

        Solution: Add Google+ Domains API in the Google Developpers Console to your project and edit/fill in your Consent Screen. Note that this whole setup works with debug keys, which means you’re the only one who could use them. When you release the app you must change them to release keys. That way it works for me.

        An other possibility is to integrate the SocialAuth-Android and SocialAuth SDKs in your project, that way you can access multiple social networks through a uniform interface with public/private key pairs (so not via the Google+ or Facebook app for instance). I integrated this in my current application and it’s a fantastic API.

        • Tonyoh87

          how do you do this with Eclipse ? I don’t use the google developpers console…

          • Matthias

            It has nothing to do with your IDE. The Google Developpers Console is a website. Depending on your settings/permissions, an app can or cannot fail. You don’t have to change your code or environment for setting up the permissions. If you use your app you contact Google somehow and they check your permissions.

        • Amintas

          Awesome Matthias, I did the first option and it worked for me!

          “Add Google+ Domains API in the Google Developpers Console to your project and edit/fill in your Consent Screen.”


  • shashi shiva

    I’am getting internal error in a real devise when signing in. When i run on emulater, it displays a message “This app won’t run without Google Play services, which are missing from your phone”. Please do replay.

  • the above app works for me on my smart phone but the only thing it misses for me is the formatting !!
    my fetched profile picture and never comes besides my name and the email id as shown above in the screenshot !! (last one containing the fetched profile )
    can any one please seem to help ?

  • Twinkle

    Thank you so much for this tutorial . but could you please update tutorials with using fragments and android studio

  • olbers

    this is nice tutorial., i like that’s

  • Nikhil

    how do we revoke access from another activity?

  • Guest123

    HIii Ravi..,i have tried integrating G+ login in my app .. but it is showing an error ..”An Internal Error Occurred” .. Please help me to resolve it ..

    • Bracebie

      Check ur client ID in Google developer console again. Maybe u have fill the wrong package name or wrong HASH key. And don’t forget to fill ur email in “Crescent screen” in the APIs and auth tab.

  • Guest123

    i have one more question,when we login through facebookSDK it takes the app_id generated by facebook, but in this don’t we need app_id genrated by google,if yes then from where we are passing that..??

    • Bracebie

      It generated by client ID in the Google developer console website. When u create the client ID you need to put the correct information about ur app’s package name and HASH key.

  • Gerard Caceres

    hello ..

    good contribution ..

    but I always get “internal error” may be happening.


    mGoogleApiClient.isConnecting ()

    returns false

    • Mohamed Tlili

      I have same problem I resolve it by creating a new project in the console of google developper be carefull the name of the project is same name of your project and activate Goole API

      • Gerard Caceres

        yes, me and set this right ..

        but it keeps coming out the same error message ..

        • Bracebie

          You need to put ur email in the “Cresent screen” below APIs and auth tab in the Google Developer Console.

  • Sachin Fulzele

    I have fix “internal error” problem and even after creating 10 different client IDs with different SHA and package name, it doesn’t work…
    until I found out that you have to fill the “Consent screen” in your account.

    • Pankaj Pardhi

      Thank you Sachin. I think also the Blog must also needs to be updated with the correction that you have provided. Mr Ravi Tamada, this seems to be the common problem for most of the people if you read the comments. Please make a note about it.

      • Thanks @sachinfulzele:disqus & @pankajpardhi:disqus. I’ll update this post, even I still have to find out exact reasons for Internal Error.

        • Goku

          Did you find anything? i just started developing for android. Ass i came accross the same problem, i cant find any sollusion.

        • Wes

          Hey Ravi. Awesome tutorial! You really know how to make things pretty succinct! I noticed a lot of people complaining about the whole internal server error. I read somewhere that the keystore SHA1 fingerprint on the development device sometimes expires. To get a fresh one, just delete the debug.keystore file from folder and then rebuild any app again in Eclipse. Then when you go to Window–>preferences–>android–>build, you’ll see a new debug SHA1 fingerprint. Copy that fingerprint and paste it in your Android Client ID generator for your app on developer console. The rest of the steps remain the same again. Maybe it will clear the error. Just a thought.

  • Diane Bevington

    Hi everybody, is anyone else running into a problem where only the first user can sign in indefinitely? I can’t figure out how to switch emails!!

    I am running into a fault where now that I have logged in with my gmail account, I cannot choose which email to log in with anymore. The first screen popped up where I accepted “dibe****”. Now, even after pressing the “Revoke Access” button, when I hit sign back in, it still takes me to my access page, already with my picture and information.

    My question is: how do I allow others to log in to this app????

    • Kevin C

      I’m having the exact same problem right now..

  • Kevin C


    First of all, thanks for the tutorial. Everything works as I want it except for one last thing:

    If I restart the app, or after an user has Revoked Access, and then I click on the Google+ log-in button, I immediately go to the Permissions screen with the last logged-in user, instead of the Google+ log-in screen?

    I thought the Revoke Access would make me able to log-in again with a different (or the same) Google+ account with Google+ account & password, but instead I’m skipping this step for some reason and go to the Permission Screen of the last logged-in user..

    How do I fix this having the same code as you’ve shown above?

    Thanks in advance for the response,

    Kevin C

    • Kevin C

      Ok, I did figure out how to switch accounts, but it’s done through the Device Settings itself. Settings -> Accounts -> Google -> Add account (and I’ve deleted the other account).

      Still, is there a way to Log-in with Google+ email & password inside the app, instead of changing the Settings first and then go to the app?

      Kevin C

      • Kevin C

        Does someone know how to make a Login Screen, so you log-in with a Google Account by typing e-mail & password, instead of using the Android Device’s Account (and right now it’s also only using the last logged in Account..)

  • amr khamis

    hey can i use this login authentication for using youtube features for example posting likes for a certain video or comments ?? can u make a tutorial how to login to youtube account and use its api for making likes and comments and subscribing ??

  • সাদ মাহমুদ

    Getting NullPointerException in GoogleApiClient.Builder(this).addApi(Plus.API, null) of Activity class.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addOnConnectionFailedListener(this).addApi(Plus.API, null)
    // Any Help ?

    • harsg014

      first write these two lines….

      PlusOptions.Builder pl = PlusOptions.builder();
      PlusOptions options =;

      then replace “null” to “options” in the below statement…

      mGoogleApiClient = new GoogleApiClient.Builder(this)
      .addOnConnectionFailedListener(this).addApi(Plus.API, options)

      it’ll work now.

    • Mihir3646

      Just remove second parameter.

      mGoogleApiClient = new GoogleApiClient.Builder(this)

      it’ll work for me.

  • ravipatel

    Hello i try to run this app on my device but it give me error “unfortunatly G+ Login has stopped” please help me in this.

    • Bracebie

      It works for me just remove the second parameter (Plus.API, null) => (Plus.API)

      mGoogleApiClient = new GoogleApiClient.Builder(this)

  • anand

    Your tutorial is very useful for my view. but now am having my own created android apps. and your tutorial apps.. and how to open my apps via google plus account(gmail)..I dont have any idea to do this please help me……

  • abhishek

    Why aint there any login form ? I mean where will user enter his Google credentials..!

    • Marcus Vinicius Andreo Gabilhe

      The G+ log in takes care of it. If the user is already logged in with Google on his phone it just needs to press OK to log in. Otherwise the user will be taken to a inner browser window to sign in with google.

  • Tanakhon Kaewkunha

    I have run your code then logcat show this…

    java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.gpluslogin/info.androidhive.gpluslogin.MainActivity}: java.lang.NullPointerException: Null options are not permitted for this Api

  • Victor Wjugow

    love you, just that.
    Oh if anyone is using IDEA IntelliJ here’s how you add the google_play_services library : (create an empty project, and then add an Android module that will be your app, and then follow the first answer)

  • Silvester Moradu

    Thanks a lot……

  • Humayoon

    i want to login with google drive and also login with drop box in my android app bu i am a new in android developer how can i develop plzz hel meee

  • Sunny Sarser

    when i run the app ‘an internal error occured’ help me

    • Fayiz Fareed

      if u found solution pls mail me

    • Mohd Ikram

      define your email id on developer console

  • appi24

    where you used client id in your app i cant see that

  • prasad Vdv

    I have downloaded ur code and tried
    Unfortunately G+Login, has been stopped

    and i tried copying the code in my app
    same error…!

    • There should be an error in LogCat.

      • prasad Vdv

        Unable to Start activityComponentinfo

        • The reason for the error will be somewhere in the log. Check for Caused by: line

          • Ankit Garg

            Hi Ravi,

            Thanks for the tutorial.

            I got NullPointerException for mConnectionResult which is called when g+ sign in button is clicked (resolveSigninError() method).

            How do we initialize it? I could see that it get’s initialized only in onConnectionFailed method.

  • Kamakshee

    i’m getting an error “Android library projects cannot be launched.” while running the project on AVD
    How am i suppose to deal with this error ?

    • You are not running the main project, you are running the library project. Right click on main project and run.

      Or you might marked the main project as library project. Right click -> properties -> android (on left) -> is Library (on right) – uncheck this.

  • Drew

    How would you do this using fragments? Such as in your fragments demo?

  • sagits

    Hi Ravi, awelsome tutorial. Nowadays you can get MD5 and SHA 1 fingerprint from debug key direct from eclipse > preferences > android > > build.

    • Yeah, that option is there from longtime back. Thanks for the info.

  • luis alberto

    I followed your tutorial but instead of clearing the activity i started another one withou having to hide the buttons, but i ran into the following problem:


    I followed your tutorial .In my Google Plus Android Application;;

    packages are not imported.please help mae What i will do

  • sandeep

    I am getting error as GoogleApiClient cannot be resolved to a type . also same error for SignInButton . Am i missing something ?

  • chaitanya

    Hey I have followed the tutorial and added G+ sign to my app. But I am unable to login … shows the following error “ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent” etc. I have no clue whay this error shows up. I have verified my package name sha1 key etc numerous times. But couldnt figure out the reason. Any help would grateful.


    Hi, the demo is running fine, but when i try to create New Client Id in Google API console i ‘m getting

    Duplicate fingerprint

    The signing fingerprint you specified is already used by another Android OAuth2 client.
    i don’t know who to fix this issue? even i have deleted all my project with it’s client Id but still i’m getting this error, please any one guide me

  • Francesca

    Hi Ravi, how can I take the profile pic and insert it in the navigation drawer? Thank you very much. Francesca

  • Tej Huded

    Hi i did all the above which you said, but then i get an internal error has occurred!! Im stuck @ this point i need some serious help!!

    • Hi Tej,

      Internal error occurs due several reasons. Search for “Google plus android internal error”. You will see few answers in stackoverflow

    • Fayiz Fareed

      if u not found solution just try this one

      this works for me

      mGoogleApiClient = new GoogleApiClient.Builder(this) ;// need three parameters
      .addApi(Plus.API, null); //remove null

      instead of above use below

      mGoogleApiClient = new GoogleApiClient.Builder(this,this,this)

    • ankit
      • vrajesh

        thank you so much its realy help..!

  • Ashish Tiwari

    Hi Ravi, I am unable to import these packages and classes:

    What should I do?

    • I guess you haven’t added Play Services Library as mentioned in 4.2 step.

      • Jaldip katre

        I am having the same problem, The library is added still no luck..?

      • Ashish Tiwari

        I got the solution by updating the Google Play Service library. After updating I just remove the library from project and added again. Now Its working.

        • Yeah, I forgot to say update it first 🙂

          • Fernando Armando Bernal Marín

            Hello i have a same problem, executed step 4.2 this not resolve the problem, but i dont update the Google Play Service library i dont know execute this. please help me for resolved this problem, and sorry for any problem with my english i´m from México and my english not is good.

  • Ashish Tiwari

    I have added Play Service Library as you mentioned in 4.2 step, and I have added all permissions and meta tag also in Manifest File as you mentioned.

  • james grigg

    How can I save data about the loged in account. So that when they come back, i will be able to give them personalised data.

  • Samer Dawalib

    thanks for this awesome tutorial (the most complete one i’ve found so far), but i got a null pointer exception @

    mGoogleApiClient = new GoogleApiClient.Builder(this)





    • Lee Aehwa

      .addApi(Plus.API,null) -> .addApi(Plus.API)

      • Samer Dawalib


  • james grigg

    I am being sent an error from Google Play Services API saying that:

    did not call through to “super.onPostCreate()”

    My Question on stack overflow:

  • Sarvesh SB

    Why this error – ” An internal error has occured ” ?

  • Dung Nguyen VN

    Can it work without ConnectionCallbacks andOnConnectionFailedListener?

  • Hi ravi why i always get

    08-28 23:37:38.557: E/AndroidRuntime(28591): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{}: java.lang.ClassNotFoundException: Didn’t find class “” on path: DexPathList[[zip file “/data/app/”],nativeLibraryDirectories=[/data/app-lib/, /vendor/lib, /system/lib]]

    this just happend when I intent to activity from this tutorial.

    thanks for your tutorial

    • this is my error from downloaded project of yours

      08-29 09:26:36.945: E/AndroidRuntime(3816): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{info.androidhive.gpluslogin/info.androidhive.gpluslogin.MainActivity}: java.lang.ClassNotFoundException: Didn’t find class “info.androidhive.gpluslogin.MainActivity” on path: DexPathList[[zip file “/data/app/info.androidhive.gpluslogin-2.apk”],nativeLibraryDirectories=[/data/app-lib/info.androidhive.gpluslogin-2, /vendor/lib, /system/lib]]

  • Marcos Campos

    Hi Ravi, error detected!

    09-03 21:56:57.015: E/AndroidRuntime(26306): Caused by: java.lang.NullPointerException: Null options are not permitted for this Api

  • Nathan

    Hi Ravi ,
    if i click G+ signin button it shows Toast as “An Internal error has occurred”.

  • Juliano Mendes

    Hi Ravi ,
    if i click G+ signin button it shows Toast as “An Internal error has occurred”.

    • Nihel

      same problem here can you please help me ?

    • Kiran Kumar

      All problems has solved…

      In the Consent window – fill up all the fields like email,product name and other optional fields (enter any URL like http://localhost ) enter the same URL(http://localhost) for product logo field. And don’t enter anything in GOOGLE+ Page field, leave as what is there and click save…
      Now run the app, it works fine …………..

  • Juliano Mendes

    Ravi, problem solved!

  • keith

    Thank your help !!! All problem were solved!!
    This is a good article so that help me solve Google Login problem 🙂

  • Android_Rocks

    every time when i click G+ signin button it shows Toast as “An Internal error has occurred”.
    please help me

    > and second thing , when you use g+ api, because only create not use client id or use not specify any where.
    > without client id google how to know which project through request comes.

    >please solve my problem fast as soon as possible.

    • VladMurray
    • Android_Rocks

      i solve internet error bug.
      first you use sign in apk file in android device and also use sign in apk sha1 certificate key
      not use cmd key its not working

      so please ravi update this tutorial .
      all the thing use shown its working

      THANKS Ravi Such a Great Tutorial
      its working great.

      • Pankaj Chauhan

        Sir please tell me how you solved this problem in simple words. Please sir.

        • Android_Rocks

          ok give me some time i can help you sure.

          • Android_Rocks

            Sorry For Delay ,

            one thing you change ,

            first step you must change :- SHA1 fingerprint

            click on this

            through this my problem solve

  • Nisha jain

    I got this error when i run this code :-

    java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.Button

    Please help me ,

    • harsha

      Plese use ImageView for ProfileImage class cast exception for while converting your image in button instead of button widget replace with imageview.

  • chaitu

    unfortunately g+login stopped..when I open app

    • chaitu

      worked after removing null here


      now getting internal error now

      • Chris Hieu

        I searched on StackOverFlow and can change code like this:
        mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addApi(Plus.API, new Plus.PlusOptions.Builder().build()) // note the options

  • Ankit

    Awesome tutorial Ravi. Thanks dude…

  • VladMurray

    Ensure You all fill out the consent section on Google Developer Portal Under APIs And Auths.

  • Nitin

    I tried to implement the code,but after clicking on sign in button a toast is coming saying internal error.while debugging it goes in onactivityresult’s and then goes into if (responseCode != RESULT_OK).Please help.

  • pkpdeveloper
  • Kamil

    Thanks Ravi, Awesome and complete tutorial. But how can I modify this to implement login without bugging my users with Google Plus? I have read, that google will shutdown other auth methods and only google+ will stay. There was also information, that users withoug google plus can log in too. But how to do it?

  • Thanks for this helpful tutorial. Really helped.

  • Chris

    Thank you very much. This is what I need.

  • Vito

    Thanks for this very helpful tutorial!!
    I need to log out of google plus from a different activity! Not the same activity which I use for login.
    Is it possible??

  • kuldeep kumar

    how to download the pdf file from google drive in android programatically in android i used many sample but not working correcly and my project deliver date is 19/11/2014 please give me some sample or any sugession please

  • Rajnish Vishwakarma

    Ravi Sir i m not getting where to put the client_secrets.json file..what is the use of it..and how to access it..Please tell.m sir…as in the above code there is no client_secrets.json file… please tell me..sir..

  • Paulo Basilio

    I get null person information

  • Ravish

    consent screen do not appear..

  • Genka Kasyan

    All did at shown in example. But have NullPointer. Have any idea??





    at Source)

    at android.view.View.performClick(

    at android.view.View$

    at android.os.Handler.handleCallback(

    at android.os.Handler.dispatchMessage(

    at android.os.Looper.loop(


    at java.lang.reflect.Method.invokeNative(Native Method)

    at java.lang.reflect.Method.invoke(



    at dalvik.system.NativeStart.main(Native Method)

  • Aaditya Sriram

    What is RESULT_OK ?

  • Jarvis

    Hi Ravi,
    I am able to connect to the login but when retirving the information its is saying person information null. Can you please help me with that. Also I want to retrieve the token that gets generated when the user gets logged in so if you have a tutorial for that also please share that.

  • Chitrita Ghosh


    I was getting this error java.lang.nullpointerexception.

    for that I replaced the below

    mGoogleApiClient = new GoogleApiClient.Builder(this)


    .addOnConnectionFailedListener(this).addApi(Plus.API, null)



    mGoogleApiClient = new GoogleApiClient.Builder(this)




    Other than this It worked for me. The code was really helpful. Thanks

    • Carlos Suazo

      Change this
      .addOnConnectionFailedListener(this).addApi(Plus.API, null)

      for this
      .addOnConnectionFailedListener(this).addApi(Plus.API, Plus.PlusOptions.builder().build())

      let me know

    • 1ayushi .

      Thanks dear its working now

  • Vishnu Sharma

    Can i include two or more google plus apis with Single gmail address

  • Tushar Salvi

    your tutorial works great for me, but i m having 1 question how can i logout g+ from other activity

    • Pankaj Chauhan

      Brother is code running without any internal error?

      • Tushar Salvi

        yes, actually internal error cause when you inserting wrong package name in Google APIs console putting your package name from manifest.xml file it will work for sure

        • Pankaj Chauhan

          Thank you Tushar.

  • Pankaj Chauhan

    how to resolve internal error problem. Please help me.

    • piyush

      please check that have you developed client id or app id to resolve this error you have to develop a client id outh

  • Pankaj Chauhan

    Wooo yes man i run this code listen everybody this code is right to run it. First delete the null parameter from mGoogleApiClient = new GoogleApiClient.Builder(this)

    Second in this google developer console is not properly describe here the link
    it help you.

  • Pankaj Chauhan

    Thank you very much Ravi sir for your code. can tell me how to fetch the contact of this user which we login with this code?

  • Parth Rajnai

    Hello, how to logout g+ from another activity..??
    i have tired to finding solution of it.

    • Keya

      Parth, you can store the GoogleApiClient in a Singleton class which can be accessed from another activity. I am doing so in my code. Else you can re-write the whole “GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();”

      And in the onConnect method, do the log out.

  • Akash KV

    mConnectionResult is null

    • Paranoiddroid

      I get that too

  • Redturbo5

    I have done all things in this tutorial, but there was some import that always error :


  • Shashank Kumar

    How do I get instance of GoogleApiClient on other Activities to access user info or logout user?
    How how can get its instance when we quit the application and relaunch again..thanks

  • vitrag

    Persona information is null…user is connected

  • ken

    do you know how to get other account information like birthday, gender..? i tried to use the available methods– getBirthday(), getGender(), but they didn’t work..

  • Sanwal

    Thanks for this nice tutorial sir, I am big fan of you,

  • javer

    I was wondering hoy do you post something in the wall using your app?

  • Pratik Borole

    Just tried the tut. App crashed after running. Null Pointer Exception at addOnConnectionFailedListener(this).addApi(Plus.API, null)

    please remove the null argument when initializing mGoogleApiClient – should be

    definitely works now. The error occurred because Null options are not permitted for Google plus API.

  • Alan

    Hey, Great tut, thanks for sharing.

    I want to know how can I open MainActivity after successful sign in with a G+ account.


  • Hung Nguyen

    Thanks for your tut. It helped me a lot.