Want to let users log in to your Android app with their Google account? This tutorial shows you how to add Google Sign-In in Android the modern way using Jetpack Credential Manager and Google Identity Services. It’s written for students and beginners learning Android with Kotlin/Java, and it follows the latest 2026 best practices (no legacy GoogleSignInClient or One Tap). By the end, you’ll have a working sign-in flow with the new Credential Manager bottom sheet and a dedicated “Sign in with Google” button, plus tips for Firebase Auth and backend verification.
What is Google Sign-In on Android and when should you use it?
Google Sign-In lets users authenticate with their Google account to access your app. It reduces friction, increases conversion, and avoids managing passwords yourself. As of 2026, the recommended Android implementation uses Jetpack Credential Manager together with Google Identity Services (googleid). This unifies credentials (passwords, passkeys, and Sign in with Google) in a single, privacy-respecting bottom sheet, and also supports a dedicated “Sign in with Google” button for explicit login.
- Modern, secure, and familiar to users
- Works on API 19+ with automatic sign-in support for returning users
- Simple integration with your backend and optional Firebase Authentication
Credential Manager vs legacy approaches (quick comparison)
| Feature | Credential Manager + Google Identity | Legacy GoogleSignInClient / One Tap |
|---|---|---|
| Status for new apps | Recommended path in Android docs | Superseded for new apps |
| UX | Unified bottom sheet + “Sign in with Google” button | Separate Google UI flows |
| Credential types | Passkeys, passwords, Google sign-in in one API | Google sign-in only |
| Automatic sign-in | Auto-select for returning users | Limited/extra boilerplate |
| Backend verification | ID token via GoogleIdTokenCredential (audience = Web client ID) | Easier to misconfigure audience/flow |
| Firebase | Pass ID token to FirebaseAuth (GoogleAuthProvider) | Older, separate integration path |
What you’ll build
We’ll implement two UX paths:
- Automatic sign-in via Credential Manager bottom sheet (for returning/authorized accounts)
- A branded “Sign in with Google” button for manual sign-in
We’ll request a Google ID token, parse it with GoogleIdTokenCredential, and explain how to verify it on your backend. We’ll use Kotlin and Jetpack Compose for UI, and show a minimal Java/XML example for classic views.
Prerequisites
- Android Studio latest stable (Giraffe or newer recommended)
- Min SDK: 19+ (Credential Manager supports API 19 and above)
- Basic Kotlin knowledge (Java snippet included)
- A Google Cloud project to create OAuth client IDs
- Optional: Firebase project if you want to sign in to Firebase using the Google ID token
- Optional: Your own backend to verify Google ID tokens and create app sessions
Pre‑flight checklist: How to add Google Sign-In in Android
- Create two OAuth clients in the same Google Cloud project: Web and Android (package + correct SHA‑1).
- Put the Web client ID in
strings.xmlasserver_client_id; addINTERNETpermission. - Auto flow: use
GetGoogleIdOptionwithsetFilterByAuthorizedAccounts(true)and optionalsetAutoSelectEnabled(true). - Manual flow: use
GetSignInWithGoogleOptionbehind a “Sign in with Google” button. - Parse with
GoogleIdTokenCredential; sendidTokento your backend over HTTPS. - On the server, verify iss, aud = Web client ID, exp, and optionally hd.
- Handle user cancel/no accounts (
NoCredentialException) by showing the manual sign-in button. - Firebase users: pass
idTokentoGoogleAuthProvider; don’t use legacyGoogleSignInClient. - Add both debug and release SHA‑1. If using Play App Signing for production, include the App Signing SHA‑1.
- Test on emulator/physical device with a Google account; keep Google Play services and libraries up to date.
Step 1 — Configure OAuth in Google Cloud (Web & Android client IDs)
This is important. You need two OAuth clients in the same Google Cloud project:
- Web client ID — Used by your Android app to request a server-verifiable ID token. You’ll pass this ID as
serverClientId. - Android client ID — Tied to your app’s package name and SHA‑1. This allows Google Identity Services to recognize your app.
Create the OAuth clients
- Open Google Cloud Console > APIs & Services > Credentials.
- Click “Create Credentials” > “OAuth client ID”. If prompted, configure the OAuth consent screen.
- Create a Web application client. Copy its Client ID (it ends with
.apps.googleusercontent.com). This is your serverClientId. - Create an Android client:
- Enter your app’s Package name (e.g.,
com.example.myapp). - Add your SHA-1 certificate fingerprint (see below).
- Enter your app’s Package name (e.g.,
How to get the SHA‑1 key in Android Studio
- Via Gradle: In Android Studio, open the Gradle tool window > Your Module > Tasks > android > signingReport. Check the Variant: debug block for SHA1. Use your release SHA‑1 for production.
- Via command line (debug):
./gradlew signingReport
Add the SHA‑1 to the Android OAuth client in Cloud Console and save.
Important: Always use the Web client ID for serverClientId when requesting an ID token on Android. This ensures you receive a token your backend can verify.
Step 2 — Add dependencies
In your app module’s build.gradle (Kotlin DSL shown; adjust for Groovy if needed):
Check the latest versions in the Jetpack Credentials release notes and Google Identity Services docs before you build.
Step 3 — Add your Web client ID to resources
Create a resource to store your Web client ID:
If you plan to call your backend from the app, ensure you have Internet permission:
Step 4 — Implement Google Sign-In with Credential Manager (Kotlin + Compose)
We’ll create two flows:
- Auto sign-in using
GetGoogleIdOptionwith authorized accounts and optional auto-select - Manual button using
GetSignInWithGoogleOption
Compose: a branded “Sign in with Google” button
Use Google’s branding guidelines (padding, white button, Google “G” logo). You can use a vector asset for the Google “G” logo.
Kotlin: request an ID token with Credential Manager
The following Activity demonstrates both the auto and manual flows, parses the result with GoogleIdTokenCredential, and exposes the ID token you should send to your backend.
At this point, you’re successfully retrieving a Google ID token on Android. Your app should send this token to your backend over HTTPS. On the server, verify:
- Signature (using Google public keys)
- Issuer is accounts.google.com or https://accounts.google.com
- Audience equals your Web client ID
- Expiry is valid
- Optional:
hdclaim matches a Workspace domain you require
This server-side verification is required to trust the sign-in.
Sign-in data flow (Credential Manager + Google Identity)
GoogleIdTokenCredential with idTokenidToken to your backend via HTTPSSign out
To sign the user out of your app session, clear your local state and optionally call Credential Manager to reset saved state:
If you use Firebase Authentication, also call FirebaseAuth.getInstance().signOut().
Step 5 — Optional: Use Firebase Authentication with the ID token
If your app uses Firebase as its backend, you can still use Credential Manager to get the Google ID token and then pass it to Firebase Auth. This keeps your sign-in modern while leveraging Firebase sessions:
Note: Do not use the legacy GoogleSignInClient/GoogleSignInOptions flow with Firebase. Credential Manager is the modern path.
Step 6 — Classic Views: minimal Java example
If you’re learning Java/XML, here’s a minimal Activity using a standard button and the explicit Google sign-in flow. This uses the async API with a callback.
Example XML layout:
Result: what you’ll see
- Returning users may be signed in automatically or shown a bottom sheet with their Google account.
- New users can tap the “Sign in with Google” button to pick an account.
- You’ll receive an ID token in your app; send it to your backend (or Firebase) to finish authentication.
- On success, navigate to your app’s home screen and store the session returned by your backend.
Troubleshooting and common fixes
- NoCredentialException: The user canceled or no authorized accounts are available. Show the manual “Sign in with Google” button.
- Token audience mismatch: Verify that the token’s audience matches your Web client ID, not the Android client ID.
- SHA‑1 mismatch: Ensure the SHA‑1 in your Android OAuth client matches the keystore you’re using (debug vs release). Re-run
signingReportand update Cloud Console if needed. - Consent screen errors: Complete OAuth consent screen setup in Google Cloud. If your app is unverified and requests sensitive scopes, follow verification steps.
- Network/403: Check that both Web and Android clients are in the same Google Cloud project. Ensure you’ve enabled the necessary Google APIs.
- Firebase errors: If using Firebase, keep your Firebase BoM and Auth SDK up to date. Use the ID token from Credential Manager with
GoogleAuthProvider, not legacy GoogleSignInClient.
FAQ: People also ask
What is Google Sign-In in Android and why should I use it?
It lets users log in with their Google account, removing the need to manage passwords and improving conversion. The modern approach (Credential Manager + Google Identity Services) also integrates with passkeys/passwords for a smoother, safer experience.
Do I need Firebase to add Google Sign-In to my Android app?
No. You can use Credential Manager to get an ID token and verify it on your own backend. Firebase is optional if you want Firebase-managed sessions; if you use it, pass the ID token to FirebaseAuth.
How do I get the SHA-1 key for Google Sign-In in Android Studio?
Run the signingReport Gradle task (in Android Studio’s Gradle window or via ./gradlew signingReport). Use the SHA‑1 from your debug or release keystore as appropriate and add it to the Android OAuth client in Google Cloud.
How can I add Google Sign-In in Android using Kotlin or Java?
Use Jetpack Credential Manager with Google Identity Services. In Kotlin, call the suspend getCredential API; in Java, use getCredentialAsync with a callback. Parse the result with GoogleIdTokenCredential and send the idToken to your backend or Firebase.
Why is Google Sign-In not working in my Android app and how do I fix it?
Common causes include SHA‑1 mismatch, using the Android client ID instead of the Web client ID as serverClientId, unconfigured consent screen, or outdated libraries. Check logs, verify OAuth setup, and use the troubleshooting guide linked below.
Key takeaways
- The best way for 2026 is Credential Manager + Google Identity Services (googleid).
- Always request the ID token using your Web client ID (
serverClientId). - Verify the ID token on your backend before creating a session.
- Offer both auto sign-in and a “Sign in with Google” button for best UX.
- Avoid legacy APIs like
GoogleSignInClientand One Tap; they’ve been replaced by Credential Manager flows.
Sources / Further reading
- Implement Sign in with Google (Android)
- About Sign in with Google (Android)
- GetGoogleIdOption reference
- GetSignInWithGoogleOption reference
- GoogleIdTokenCredential reference
- Jetpack Credentials release notes
- Troubleshoot Credential Manager
- Authenticate with Google on Android (Firebase Auth)
Wrapping up
That’s how to add Google Sign-In in Android using the newest, officially recommended approach. If you’re building a new app or updating an existing one, move to Credential Manager to simplify your auth code, support passkeys alongside Google, and improve sign-in conversion. Pair it with a secure backend that verifies ID tokens, or plug it into Firebase Auth if you prefer. Happy building!
