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.4 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 15.0.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.4 (KitKat) or newer.
This guide is written for users of Android Studio, which is the recommended development environment.
Add Google Play services
In your project's top-level build.gradle
file, ensure that Google's Maven
repository is included:
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
}
}
Then, in your app-level build.gradle
file, declare Google Play services as a
dependency:
apply plugin: 'com.android.application'
...
dependencies {
implementation 'com.google.android.gms:play-services-auth:20.4.1'
}
Configure a Google API Console project
To configure a Google API Console project, click the button below, and specify your app's package name when prompted. You will also need to provide the SHA-1 hash of your signing certificate. See Authenticating Your Client for information.
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:
- Open the Credentials page in the API Console.
- 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.