This page refers to a deprecated version of Google Sign-In. New projects should use the current version.

Try Sign-In for Android

Use our Android sample app to see how Sign-In works, or add Sign-In to your existing app.

Required: The latest versions of Android Studio and Google Play Services.

Get the project

If this is your first time using a Google services sample, check out the google-services repository.

$ git clone https://github.com/googlesamples/google-services.git

Open Android Studio.

Select File > Open, browse to where you cloned the google-services repository, and open google-services/android/signin.

Get a configuration file

To use the sample, you need to provide some additional information to get a configuration file and finish setting up your project. Use the package name com.google.samples.quickstart.signin for the sample.

After you complete the registration, download the google-services.json file to add to your project.

Get a Configuration File

Add the configuration file to your project

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane:

Mac/Linux
$ mv path-to-download/Downloads/google-services.json app/
Windows
$ move path-to-download/Downloads/google-services.json app/

Run the sample

Now you're ready to build the sample and run it from Android Studio.

Build the sample and click the run button and select a connected device or emulator with Google Play Services 9.8.0 or newer.

How it works

The application builds a GoogleApiClient, specifying which scopes and APIs the application will access. When the GoogleApiClient connects, the user is signed in.

// Build GoogleApiClient with access to basic profile
mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API)
        .addScope(new Scope(Scopes.PROFILE))
        .addScope(new Scope(Scopes.EMAIL))
        .build();

Next steps

If you want to see how you can implement Google Sign-In in your own app, take a look at our implementation guide.

Add Sign-In to your app

Did you have a good experience? Run into trouble? Let us know!