You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android添加Sign in with Google按钮失败,求排查方案

添加「Sign in with Google」按钮失败排查求助

问题现象

  • 使用SignInWithGoogleOption时触发错误:activity is cancelled by the user(实际并非用户主动取消)
  • 使用GoogleIdOption时触发错误:During begin sign in, failure response from one tap: 10: [28444] Developer console is not set up correctly (android.credentials.GetCredentialException.TYPE_NO_CREDENTIAL)

当前运行环境

应用通过Android Studio以debug构建变体运行,包名为com.example.name.debug

已尝试但无效的排查方案

  • Google Cloud项目中已创建com.example.name.debug和com.example.name的Android类型OAuth 2.0客户端ID;webClientId已配置为Web应用类型客户端ID
  • Release和Debug构建变体使用同一.jks签名文件,SHA1签名值完全一致
  • 执行./gradlew signingreport输出的SHA1值,与云端客户端配置的SHA1完全匹配

项目依赖配置

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"

核心实现代码

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())
    }
}

求助

请问还有哪些可行的排查方案可以尝试?


内容的提问来源于stack exchange,提问作者Viewed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 14:55:14