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

android-google-plus-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 ‘com.google.gms:google-services:3.0.0’ class path to dependencies.

dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }

3.3. Open app level build.gradle and add ‘compile com.google.android.gms:play-services-auth:9.2.1’ to dependencies. At the bottom of the file, add apply plugin: ‘com.google.gms.google-services’

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

dependencies {
    // ..
    compile 'com.google.android.gms:play-services-auth:9.2.1'

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

apply plugin: 'com.google.gms.google-services'

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

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <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>
</resources>

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="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/llProfile"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:orientation="horizontal"
        android:weightSum="3"
        android:visibility="gone">

        <ImageView
            android:id="@+id/imgProfilePic"
            android:layout_width="80dp"
            android:layout_height="wrap_content" 
            android:layout_weight="1"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:orientation="vertical"
            android:layout_weight="2" >

            <TextView
                android:id="@+id/txtName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/txtEmail"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:textSize="18dp" />
        </LinearLayout>
    </LinearLayout>

    <com.google.android.gms.common.SignInButton
        android:id="@+id/btn_sign_in"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_marginBottom="20dp"/>

    <Button
        android:id="@+id/btn_sign_out"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/btn_logout_from_google"
        android:visibility="gone" 
        android:layout_marginBottom="10dp"/>

    <Button
        android:id="@+id/btn_revoke_access"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/btn_revoke_access"
        android:visibility="gone" />

</LinearLayout>

3.6 . Now open MainActivity.java 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.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
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;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.OptionalPendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;

public class MainActivity extends AppCompatActivity implements
        View.OnClickListener,
        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;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnSignIn = (SignInButton) findViewById(R.id.btn_sign_in);
        btnSignOut = (Button) findViewById(R.id.btn_sign_out);
        btnRevokeAccess = (Button) findViewById(R.id.btn_revoke_access);
        llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);
        imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic);
        txtName = (TextView) findViewById(R.id.txtName);
        txtEmail = (TextView) findViewById(R.id.txtEmail);

        btnSignIn.setOnClickListener(this);
        btnSignOut.setOnClickListener(this);
        btnRevokeAccess.setOnClickListener(this);

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();

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

        // Customizing G+ button
        btnSignIn.setSize(SignInButton.SIZE_STANDARD);
        btnSignIn.setScopes(gso.getScopeArray());
    }


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


    private void signOut() {
        Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(Status status) {
                        updateUI(false);
                    }
                });
    }

    private void revokeAccess() {
        Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(Status status) {
                        updateUI(false);
                    }
                });
    }

    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);

            txtName.setText(personName);
            txtEmail.setText(email);
            Glide.with(getApplicationContext()).load(personPhotoUrl)
                    .thumbnail(0.5f)
                    .crossFade()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(imgProfilePic);

            updateUI(true);
        } else {
            // Signed out, show unauthenticated UI.
            updateUI(false);
        }
    }

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

        switch (id) {
            case R.id.btn_sign_in:
                signIn();
                break;

            case R.id.btn_sign_out:
                signOut();
                break;

            case R.id.btn_revoke_access:
                revokeAccess();
                break;
        }
    }

    @Override
    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);
            handleSignInResult(result);
        }
    }

    @Override
    public void onStart() {
        super.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();
            handleSignInResult(result);
        } 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.
            showProgressDialog();
            opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                @Override
                public void onResult(GoogleSignInResult googleSignInResult) {
                    hideProgressDialog();
                    handleSignInResult(googleSignInResult);
                }
            });
        }
    }

    @Override
    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);
            mProgressDialog.setMessage(getString(R.string.loading));
            mProgressDialog.setIndeterminate(true);
        }

        mProgressDialog.show();
    }

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

    private void updateUI(boolean isSignedIn) {
        if (isSignedIn) {
            btnSignIn.setVisibility(View.GONE);
            btnSignOut.setVisibility(View.VISIBLE);
            btnRevokeAccess.setVisibility(View.VISIBLE);
            llProfileLayout.setVisibility(View.VISIBLE);
        } else {
            btnSignIn.setVisibility(View.VISIBLE);
            btnSignOut.setVisibility(View.GONE);
            btnRevokeAccess.setVisibility(View.GONE);
            llProfileLayout.setVisibility(View.GONE);
        }
    }
}

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.

android-google-plus-sign-in-choosing-the-account
android-sign-in-with-google-plus-account
Change Log

Updated On 2nd Sep 2016 (Content Update, Bug fixes)
Subscribe
Notify of
guest
465 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Nicolas
Nicolas
6 years ago

Hi,

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

Ravi Tamada
6 years ago
Reply to  Nicolas

You are welcome 🙂

Cristiana
Cristiana
6 years ago
Reply to  Ravi Tamada

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

Jeffy Lazar
Jeffy Lazar
6 years ago

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 🙂 🙂

Ravi Tamada
6 years ago
Reply to  Jeffy Lazar

Thanks Lazar.

Vaibhav
Vaibhav
6 years ago

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

Ravi Tamada
6 years ago
Reply to  Vaibhav

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

Vaibhav
Vaibhav
6 years ago
Reply to  Ravi Tamada

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..?

Ravi Tamada
6 years ago
Reply to  Vaibhav

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

Vaibhav
Vaibhav
6 years ago
Reply to  Ravi Tamada

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

gie
gie
6 years ago
Reply to  Ravi Tamada

adadsad

Leonardo Lopes
Leonardo Lopes
6 years ago
Reply to  Vaibhav

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:

http://developer.android.com/google/play-services/setup.html

Best regards

Leo

Ranjit Paul
Ranjit Paul
6 years ago

Getting error on Plus field

Pavlos
Pavlos
6 years ago

Keep up the great work mate!! Congrats!

Sushil
Sushil
6 years ago

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
Dave
6 years ago

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
mina mohsen
6 years ago

iam getting this error in the xml file:-
The following classes could not be instantiated:
– com.google.android.gms.common.SignInButton

and the button is not seen

Andrew
Andrew
6 years ago
Reply to  mina mohsen

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

mina mohsen
mina mohsen
6 years ago
Reply to  Andrew

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

Andrew
Andrew
6 years ago
Reply to  mina mohsen

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
Craig
6 years ago

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
Anil Chahal
6 years ago
Reply to  Craig

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

wladimir
wladimir
6 years ago
Reply to  Craig

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

Connie Leung
Connie Leung
6 years ago

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

Anil Chahal
Anil Chahal
6 years ago

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

Kumar
Kumar
6 years ago

Good work Ravi..Nice blog for android community

Matthew Wood
6 years ago

Once again a very simple and easy to understand tut.

Thanks very much! Your a great help

Matt

Barka Tatama
6 years ago

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?

Barka Tatama
6 years ago
Reply to  Barka Tatama

worked after updating google play services, awesome tutorial again

Phuc Nguyen
Phuc Nguyen
6 years ago

Great article! Thanks so much

Hasnain Ali
Hasnain Ali
6 years ago

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

Rami
Rami
6 years ago

I got “An internal error occur”

Sumit Ingewar
Sumit Ingewar
6 years ago
Reply to  Rami

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

Vihang
Vihang
6 years ago

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

Riyas V
Riyas V
6 years ago

Great tutorial man, Thank you very much.

Tugsbayar
Tugsbayar
6 years ago

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

Guest
Guest
6 years ago

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 com.google.android.gms.common.SignInButton

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.ActivityThread.access$600(ActivityThread.java:141)

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)

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

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

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.ActivityThread.main(ActivityThread.java:5103)

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(Method.java:525)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

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 com.google.android.gms.common.SignInButton

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

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

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

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

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

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

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.Activity.setContentView(Activity.java:1895)

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

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.Activity.performCreate(Activity.java:5133)

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

03-02 09:56:23.745: E/AndroidRuntime(1536): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)

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(Constructor.java:417)

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

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: com.google.android.gms.R$drawable

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.internal.ei.b(Unknown Source)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.internal.ei.a(Unknown Source)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.common.SignInButton.c(Unknown Source)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.common.SignInButton.p(Unknown Source)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.common.SignInButton.setStyle(Unknown Source)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.common.SignInButton.(Unknown Source)

03-02 09:56:23.745: E/AndroidRuntime(1536): at com.google.android.gms.common.SignInButton.(Unknown Source)

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

;)
;)
6 years ago
Reply to  Guest

Check the Id od the buttons you have used..

Guest
Guest
6 years ago

this part of source doesn’t work for me

ravi kiran
ravi kiran
6 years ago

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

Guest
Guest
6 years ago

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

Mahesh kavathiya
Mahesh kavathiya
6 years ago

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

Wa
Wa
6 years ago

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

Pinal Jakhar
Pinal Jakhar
6 years ago

Hi..

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
Mahesh kavathiya
6 years ago
Reply to  Pinal Jakhar

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
Pinal Jakhar
6 years ago

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
Mahesh kavathiya
6 years ago
Reply to  Pinal Jakhar

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

Pinal Jakhar
Pinal Jakhar
6 years ago

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

İbrahim Gökyar
6 years ago
Reply to  Pinal Jakhar

thanks…

adu
adu
6 years ago

I have an error: com.google.android.gms.plus.Plus cannot be resolved.

Abdul Wasi
Abdul Wasi
6 years ago
Reply to  adu

have you solve this problem? i have same issue

Mamro Kirill
Mamro Kirill
6 years ago

G + Returns age and a floor?

ram
ram
6 years ago

Thank you very much…

Shree
Shree
6 years ago

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.

Thanks,

Sushilkumar Yadav
Sushilkumar Yadav
6 years ago

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 ..

Francesco Nobilia
6 years ago

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
ramadon
6 years ago

can u show me detail ? I got this problem too

Akhil chandran
Akhil chandran
6 years ago

how to edit the Consent screen. please help

Gregory Galera
Gregory Galera
6 years ago

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
Matthias
6 years ago

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

Tonyoh87
Tonyoh87
6 years ago
Reply to  Matthias

same for me

Matthias
Matthias
6 years ago
Reply to  Tonyoh87

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
Tonyoh87
6 years ago
Reply to  Matthias

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

Matthias
Matthias
6 years ago
Reply to  Tonyoh87

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
Amintas
6 years ago
Reply to  Matthias

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.”

Thanks!

shashi shiva
shashi shiva
6 years ago

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.

Krrish Shukla
6 years ago

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
Twinkle
6 years ago

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

olbers
olbers
6 years ago

this is nice tutorial., i like that’s

Nikhil
Nikhil
6 years ago

how do we revoke access from another activity?

Guest123
Guest123
6 years ago

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
Bracebie
6 years ago
Reply to  Guest123

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
Guest123
6 years ago

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
Bracebie
6 years ago
Reply to  Guest123

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
Gerard Caceres
6 years ago

hello ..

good contribution ..

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

code

mGoogleApiClient.isConnecting ()

returns false

Mohamed Tlili
Mohamed Tlili
6 years ago
Reply to  Gerard Caceres

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
Gerard Caceres
6 years ago
Reply to  Mohamed Tlili

yes, me and set this right ..

but it keeps coming out the same error message ..

Bracebie
Bracebie
6 years ago
Reply to  Gerard Caceres

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

Sachin Fulzele
Sachin Fulzele
6 years ago

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
Pankaj Pardhi
6 years ago
Reply to  Sachin Fulzele

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.

Ravi Tamada
6 years ago
Reply to  Pankaj Pardhi

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

Goku
Goku
6 years ago
Reply to  Ravi Tamada

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

Wes
Wes
6 years ago
Reply to  Ravi Tamada

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 users.android 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
Diane Bevington
6 years ago

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****@colorado.edu”. 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
Kevin C
6 years ago

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

Kevin C
Kevin C
6 years ago

Hi,

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,

Greetz,
Kevin C

Kevin C
Kevin C
6 years ago
Reply to  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?

Greetz,
Kevin C

Kevin C
Kevin C
6 years ago
Reply to  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
amr khamis
6 years ago

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 ??

সাদ মাহমুদ
সাদ মাহমুদ
6 years ago

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

harsg014
harsg014
6 years ago

first write these two lines….

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

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

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API, options)
.addScope(Plus.SCOPE_PLUS_LOGIN).build();

it’ll work now.

Mihir3646
Mihir3646
6 years ago

Just remove second parameter.

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN).build();

it’ll work for me.

ravipatel
ravipatel
6 years ago

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
Bracebie
6 years ago
Reply to  ravipatel

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

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN).build();

anand
anand
6 years ago

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
abhishek
6 years ago

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

Marcus Vinicius Andreo Gabilhe
Marcus Vinicius Andreo Gabilhe
6 years ago
Reply to  abhishek

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.

465
0
Would love your thoughts, please comment.x
()
x