Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Flutter and app store releases

Sign in with Google on Android throws NoCredentialException

Your error

androidx.credentials.exceptions.NoCredentialException: During begin sign in, failure response from one tap1 more line it can show

Fix it fast

Most common cause, 1 of 3

The request only accepts accounts that signed in to this app before

Keep the filtered request for returning users.

Fix
suspend fun signIn(activityContext: Context) {
    try {
        requestGoogleId(activityContext, onlyAuthorized = true)
    } catch (e: NoCredentialException) {
        requestGoogleId(activityContext, onlyAuthorized = false)
    }
}

suspend fun requestGoogleId(activityContext: Context, onlyAuthorized: Boolean) {
    val option = GetGoogleIdOption.Builder()
        .setFilterByAuthorizedAccounts(onlyAuthorized)
        .setServerClientId(WEB_CLIENT_ID)
        .setNonce(generateSecureRandomNonce())
        .build()
    val request = GetCredentialRequest.Builder().addCredentialOption(option).build()
    handleSignIn(credentialManager.getCredential(request = request, context = activityContext))
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

NoCredentialException: During begin sign in, failure response from one tap means Credential Manager had no Google account to offer. GetGoogleIdOption lists only accounts that already authorized your app unless told otherwise, so new users hit it first. Catch it, retry with setFilterByAuthorizedAccounts(false), and add a GetSignInWithGoogleOption button for devices without a usable account. Applies to androidx.credentials 1.6.

  • Applies to androidx.credentials 1.6.0 (stable), androidx.credentials 1.7.0-alpha03, credentials-play-services-auth 1.6.0, Android 4.4 (API 19) and later
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Log the full message, then send the same request a second time with the authorized-accounts filter switched off. The play-services-auth bridge maps every Play services failure to this single exception type, except network errors and suspended connections, so the words after "one tap:" and the result of the second call are what separate the causes. Run it inside a coroutine.

Run this first
val retryOption = GetGoogleIdOption.Builder()
    .setFilterByAuthorizedAccounts(false)
    .setServerClientId(WEB_CLIENT_ID)
    .build()
try {
    val result = credentialManager.getCredential(
        request = GetCredentialRequest.Builder().addCredentialOption(retryOption).build(),
        context = activityContext,
    )
    handleSignIn(result)
} catch (e: NoCredentialException) {
    Log.e(TAG, "Still no credential: ${e.message}")
}

Then find the line you see in this list and open its fix:

  1. 1The request only accepts accounts that signed in to this app beforeThe retry with the filter set to false opens the account picker
  2. 2The phone or emulator holds no Google account the sheet can showThe unfiltered retry still throws, and the device has no Google account or the account wants its password again
  3. 3Sign-in prompts are switched off in the Google Account settingsAccounts exist and the button flow signs in fine, yet the bottom sheet never appears for any account

What does the error look like?

  • androidx.credentials.exceptions.NoCredentialException: During begin sign in, failure response from one tap
  • getCredential() fails with NoCredentialException and the Sign in with Google bottom sheet never opens

Cause 1 of 3

The request only accepts accounts that signed in to this app before

You seeThe retry with the filter set to false opens the account picker

Check

NoCredentialException during begin sign in is most often the authorized-accounts filter of GetGoogleIdOption at work. Its default is true, so someone who never granted your app access owns no qualifying account and the sheet stays shut. Search the code for the builder call to see what the first request sends.

Check
grep -rn "setFilterByAuthorizedAccounts" app/src/main

Fix

Keep the filtered request for returning users. When it throws NoCredentialException, build a second option with the filter set to false and call getCredential again. Google's implementation guide gives this as the sign-up path.

Fix
suspend fun signIn(activityContext: Context) {
    try {
        requestGoogleId(activityContext, onlyAuthorized = true)
    } catch (e: NoCredentialException) {
        requestGoogleId(activityContext, onlyAuthorized = false)
    }
}

suspend fun requestGoogleId(activityContext: Context, onlyAuthorized: Boolean) {
    val option = GetGoogleIdOption.Builder()
        .setFilterByAuthorizedAccounts(onlyAuthorized)
        .setServerClientId(WEB_CLIENT_ID)
        .setNonce(generateSecureRandomNonce())
        .build()
    val request = GetCredentialRequest.Builder().addCredentialOption(option).build()
    handleSignIn(credentialManager.getCredential(request = request, context = activityContext))
}

Verify

On a device whose account has never used the app, the sheet now lists the Google accounts and handleSignIn receives a GoogleIdTokenCredential.

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

The phone or emulator holds no Google account the sheet can show

You seeThe unfiltered retry still throws, and the device has no Google account or the account wants its password again

Check

Credential Manager cannot list an account that is missing from the device. Google's troubleshooting table names two triggers for NoCredentialException here: no account added at all, or accounts that need re-authentication. Emulators behave the same way. Open the device's account and sync screen to see what is signed in.

Check
adb shell am start -a android.settings.SYNC_SETTINGS

Fix

Give the sign-in screen its own Sign in with Google button built from GetSignInWithGoogleOption. Unlike the bottom sheet, that flow lets the person add an account to the device or sign an existing one in again. On a test emulator, run adb shell am start -a android.settings.ADD_ACCOUNT_SETTINGS and add a Google account before you test the sheet.

Fix
val buttonOption = GetSignInWithGoogleOption.Builder(serverClientId = WEB_CLIENT_ID)
    .setNonce(generateSecureRandomNonce())
    .build()
val request = GetCredentialRequest.Builder().addCredentialOption(buttonOption).build()
handleSignIn(credentialManager.getCredential(request = request, context = activityContext))

Verify

Tapping the button opens Google's sign-in screen even with no account present, and a credential comes back once the person signs in.

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

Sign-in prompts are switched off in the Google Account settings

You seeAccounts exist and the button flow signs in fine, yet the bottom sheet never appears for any account

Check

When accounts are present and NoCredentialException still comes back from the sheet, look at one user setting. Turning off Sign-in prompts for any Google Account on the device, under Google Account Settings > Sign in with Google, hides the bottom sheet for every account. Google notes the button flow is not affected.

Fix

Treat the sheet as a shortcut, not the only door. Keep the GetSignInWithGoogleOption button visible on the sign-in screen so these users can continue. A user who wants the sheet back turns Sign-in prompts on again for each account on the device.

Verify

With the setting back on, the sheet shows on the next getCredential call; with it off, the button still completes sign-in.

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Wrap the filtered request, the unfiltered retry and the button option in one sign-in function, so no screen calls getCredential with just one of them.
  • Before each release, run sign-in on an emulator with no Google account and on one whose account has never opened the app.
  • Send e.message from every GetCredentialException to your crash reporter; the part after "one tap:" carries the original Play services error.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: QistLock, Nuclear Home Video.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.