Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by EtherealSurveyor938

Android Debug Build Fails to Add 'Sign in with Google' Button Due to OAuth Configuration Issues

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I'm having trouble adding the Sign in with Google button in my Android debug build. I'm encountering two specific issues:

  1. When using SignInWithGoogleOption, I get the error activity is cancelled by the user even though that's not the case.
  2. When using GoogleIdOption, I receive the error During begin sign in, failure response from one tap: 10: [28444] Developer console is not set up correctly (android.credentials.GetCredentialException.TYPE_NO_CREDENTIAL).

I run the app from Android Studio using the debug variant with the package name com.example.name.debug.

I have tried the following steps based on suggestions from other SO answers:

  • Configured a Google Cloud Project with OAuth 2.0 client IDs for both com.example.name.debug and com.example.name (both set as Android types) and set the variable webClientId to the Web Application type client ID.
  • Ensured that both release and debug variants are signed with the same .jks file and that their SHA1 fingerprints match.
  • Verified that the SHA1 fingerprint reported by ./gradlew signingreport matches the one registered in the Google Cloud Console.

Here are my dependencies and code snippets:

GROOVY
implementation "androidx.credentials:credentials:1.3.0" implementation "androidx.credentials:credentials-play-services-auth:1.3.0" implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1"
KOTLIN
val webClientId = "" val signInWithGoogleOption = GetSignInWithGoogleOption.Builder(webClientId) .build() val googleIdOption = GetGoogleIdOption.Builder() .setFilterByAuthorizedAccounts(false) .setServerClientId(webClientId) .build() val request = GetCredentialRequest.Builder() .addCredentialOption(googleIdOption) //.addCredentialOption(signInWithGoogleOption) .build() val credentialManager = CredentialManager.create(this@MainActivity) lifecycleScope.launch { try { val result = credentialManager.getCredential(this@MainActivity, request) handleSignIn(result) } catch (e: GetCredentialException) { Log.e("handleSignIn", e.message.toString()) } }

I would appreciate any insights or suggestions on what else to try.

0

Comments 0

Answers 2

Views 66

2 Answers

Answer by StackOverflowTychoAI Agent 1 month ago

0

Below are several areas you can check or try to resolve the issue:

1. Verify the Web Client ID

Even though you’ve set up OAuth client IDs for your Android builds, the code is using a web client ID (passed as webClientId to both builders). Make sure that:

  • The variable webClientId contains the actual valid client ID for your Google Cloud project.
  • This client ID is of the “Web Application” type. In some cases an empty or incorrect string will cause the underlying API to misbehave, including presenting errors like “activity is cancelled by the user.”

For example, update your code to use the actual client ID:

KOTLIN
val webClientId = "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com"

2. Double-Check Package Name and SHA1 Fingerprint

Even if you checked these already, it’s good to verify:

  • The package name used in the debug build (com.example.name.debug) exactly matches one of the OAuth client entries in your Google Cloud console.
  • The SHA1 fingerprint (from ./gradlew signingReport) exactly matches the fingerprint registered for that package.
  • Sometimes minor differences (such as an extra suffix or a mismatch in the debug variant) can cause the API to reject the request.

3. OAuth Consent Screen and Test Users

Ensure that you have:

  • Properly configured the OAuth consent screen within Google Cloud Console.
  • If your app is in testing mode, added your test account (the account you’re using on the device/emulator) to the list of test users.

Misconfigured consent screens can lead to messages suggesting the developer console isn’t set up correctly.

4. Include Both Credential Options

You currently have commented out the call to add SignInWithGoogleOption to the GetCredentialRequest. While using GoogleIdOption alone is valid, sometimes including SignInWithGoogleOption helps in processing the request flow. Consider trying:

KOTLIN
val request = GetCredentialRequest.Builder() .addCredentialOption(googleIdOption) .addCredentialOption(signInWithGoogleOption) .build()

This may change the behavior and help pinpoint if one or both flows are misconfigured.

5. Clean Project and Reinstall

Sometimes changes in credentials or manifest settings aren’t picked up immediately:

  • Clean the project, rebuild it, and reinstall the app.
  • Ensure that older versions that might be cached on your device or emulator are fully removed.

6. Check Google Play Services

Finally, ensure that the device or emulator has updated Google Play Services since the credentials flow depends on these libraries being current.


By verifying these configuration details and updating your request to include both options, you should be able to pinpoint the misconfiguration in your developer console setup. If problems persist, checking detailed logcat output or even regenerating OAuth credentials (and allowing a few minutes for propagation) may help resolve the error.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Answer by NovaSentinel387 1 month ago

0

TL;DR:

Root cause could be an incorrect combination of OAuth 2.0 Client IDs (Web/Android) and SHA-1 keys or IDs already used by other apps. To avoid conflict, generate new OAuth 2.0 Client IDs and follow the setup guide. Using the latest dependency version 1.5.0-rc01 might help too.

signInWithGoogleOption; activity is cancelled by the user

While seemingly user-related, this is caused by incorrect Client ID usage.

  • When using the googleIdOption, you must provide the web client ID that is auto-generated.
  • If you're using signInWithGoogleOption, do the same but if it doesn't work, try to pass the client ID of the Android app, which you created by providing the SHA-1 and package name.

GoogleIdOption; Developer console is not set up correctly

There are different causes of this error which are not immediately clear to the developer including incorrect SHA-1 key, missing release APK, console configuration error such as using a web client instead of an android client and vice versa.

Try to copy the correct SHA1 fingerprint (from ./gradlew signingreport) of correct Variant and Config from the terminal console and configure the same in the cloud console for your app's Android OAuth2 client.

Steps to perform:

  1. Create one Android OAuth2 client in the Cloud API console with your app's package name.
  2. Use the debug SHA-1 key in this Android OAuth2 client creation as mentioned above (in order to recognize this as debug client you can append the client name with debug as "your-app-debug").
  3. Create one Web OAuth2 client in the Cloud API console. This will act as the server for your app.
  4. Copy the ClientID of this web client and use it in setServerClientId(webClientID) in your integration.
  5. (Optional) You can create another Android OAuth2 client with release key's SHA-1 fingerprint for production, and for recognizing this client, can give it a name "Your-app-release"

Credits to @Manishoaham for providing steps from this post.

No comments yet.

Discussion

No comments yet.