Start Integrating Google Sign-In into Your Android App

Before you can start integrating Google Sign-In in your own app, you must configure a Google API Console project and set up your Android Studio project. The steps on this page do just that. The next steps then describe how to integrate Google Sign-In into your app.

Prerequisites

Google Sign-In for Android has the following requirements:

  • A compatible Android device that runs Android 4.0 or newer and includes the Google Play Store or an emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or newer and has Google Play services version 11.6.0 or newer.
  • The latest version of the Android SDK, including the SDK Tools component. The SDK is available from the Android SDK Manager in Android Studio.
  • A project configured to compile against Android 4.0 (Ice Cream Sandwich) or newer.
  • The Google Play services SDK:
    1. In Android Studio, select Tools > Android > SDK Manager.
    2. Scroll to the bottom of the package list and select Extras > Google Repository. The package is downloaded to your computer and installed in your SDK environment at android-sdk-folder/extras/google/google_play_services.

This guide is written for users of Android Studio, which is the recommended development environment.

Get a configuration file

Click the button below to get a configuration file to add to your project.

The configuration file provides service-specific information for your app. To get it, you must select an existing project for your app or create a new one. You'll also need to provide a package name for your app.

When you generate the configuration file, you will also need to provide the SHA-1 hash of your signing certificate. See Authenticating Your Client for information.

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/google-services.json app/
Windows
$ move path-to-download/google-services.json app/

Add the Google Services plugin

The Google Services plugin for Gradle parses configuration information from the google-services.json file. Add the plugin to your project by updating your top-level build.gradle and your app-level build.gradle files as follows:

  1. Add the dependency to your project-level build.gradle:
    classpath 'com.google.gms:google-services:3.1.0'
  2. Add the plugin to your app-level build.gradle:
    apply plugin: 'com.google.gms.google-services'

Add Google Play Services

In your app-level build.gradle file, declare Google Play Services as a dependency:

apply plugin: 'com.android.application'
    ...

    dependencies {
        compile 'com.google.android.gms:play-services-auth:11.6.0'
    }

Get your backend server's OAuth 2.0 client ID

If your app authenticates with a backend server or accesses Google APIs from your backend server, you must get the OAuth 2.0 client ID that was created for your server. To find the OAuth 2.0 client ID:

  1. Open the Credentials page in the API Console.
  2. The Web application type client ID is your backend server's OAuth 2.0 client ID.

Pass this client ID to the requestIdToken or requestServerAuthCode method when you create the GoogleSignInOptions object.

Next steps

Now that you have configured a Google API Console project and set up your Android Studio project, you can integrate Google Sign-In into your app.