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

Google Play Console发布应用后Google登录失效,报ApiException:10求助

Google登录ApiException:10问题排查求助

核心错误:

Exception com.google.android.gms.common.api.ApiException: 10: Developer console is not setup correctly.

问题现象:
通过CI-CD在AppCenter分发的所有构建(debug、release版本)在测试、生产等环境均正常运行,但一旦通过Google Play Console发布应用,或用Play Console的App Bundle Explorer上传AAB后下载APK到本地测试,Google登录功能直接失效。

已执行的排查操作:

  • 在Google Play Console中重置上传密钥、应用签名密钥
  • 在Google Cloud Console中重新创建Android凭据(包括重新创建Web客户端,甚至尝试Firebase自动生成的凭据)
  • 尝试接入Firebase应用
  • 使用官方最新的一键登录代码实现
  • 参考Firebase教程视频调整实现逻辑
  • 将认证模块从子模块迁移至主App模块(排除子模块包名差异影响)
  • 创建仅包含Google登录按钮的全新Android Kotlin项目,仍出现相同错误
  • 多次确认使用的是Web客户端OAuth Client ID(若使用错误会有明确提示)
  • 已提交Google Cloud OAuth同意屏幕审核,当前处于待审核状态(认为此不是问题根源,因为请求的是敏感权限范围)

签名信息说明:
debug和release版本使用相同的SHA1,执行./gradlew signingReport得到的签名报告如下:

Variant: testRelease
Config: config
Store: some_path_to_store/release.jks
Alias: company
MD5: 57:MD5
SHA1: 99:SHA1
SHA-256: C3:SHA256
Valid until: Thursday, Month 9, 2045

Variant: prodRelease
Config: config
Store: some_path_to_store/release.jks
Alias: company
MD5: 57:MD5
SHA1: 99:SHA1
SHA-256: C3:SHA256
Valid until: Thursday, Month 9, 2045

目前仅创建了基于上传密钥SHA1的Google Cloud Android OAuth Client ID,曾尝试添加第二个基于Google Play签名SHA1的凭据,但无明显改善。

当前使用的代码:

package com.eight.app

import android.content.IntentSender
import android.os.Bundle
import android.util.Log
import android.widget.TextView
import androidx.activity.result.ActivityResult
import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import com.google.android.gms.auth.api.identity.BeginSignInRequest
import com.google.android.gms.auth.api.identity.Identity
import com.google.android.gms.auth.api.identity.SignInClient
import com.google.android.gms.common.api.ApiException

class MainActivity : AppCompatActivity() {

    private lateinit var errorText: TextView
    private lateinit var googleButton: TextView
    private lateinit var oneTapClient: SignInClient
    private lateinit var signInRequest: BeginSignInRequest
    private val activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult(), ::handleSignInResult)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.a_start)
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
        errorText = findViewById(R.id.errorText)
        googleButton = findViewById(R.id.googleButton)

        oneTapClient = Identity.getSignInClient(this)
        signInRequest = BeginSignInRequest.builder()
            .setPasswordRequestOptions(
                BeginSignInRequest.PasswordRequestOptions.builder()
                    .setSupported(true)
                    .build(),
            )
            .setGoogleIdTokenRequestOptions(
                BeginSignInRequest.GoogleIdTokenRequestOptions.builder()
                    .setSupported(true)
                    // Your server's client ID, not your Android client ID.
                    .setServerClientId(getString(R.string.your_web_client_id))
                    // Only show accounts previously used to sign in.
                    .setFilterByAuthorizedAccounts(false)
                    .build(),
            )
            // Automatically sign in when exactly one credential is retrieved.
            .setAutoSelectEnabled(true)
            .build()

        googleButton.setOnClickListener {
            oneTapClient.beginSignIn(signInRequest)
                .addOnSuccessListener(this) { result ->
                    try {
                        val intentSenderRequest = IntentSenderRequest.Builder(result.pendingIntent.intentSender).build()
                        activityResultLauncher.launch(intentSenderRequest)
                    } catch (e: IntentSender.SendIntentException) {
                        Log.e("oneTapSignIn", "Couldn't start One Tap UI: ${e.localizedMessage}")
                        errorText.text = "oneTapSignIn Couldn't start One Tap UI: ${e.localizedMessage}"
                    }
                }
                .addOnFailureListener(this) { e ->
                    // No Google Accounts found. Just continue presenting the signed-out UI.
                    Log.d("oneTapSignIn", e.localizedMessage)
                    errorText.text = "oneTapSignIn addOnFailureListener Couldn't start One Tap UI: ${e.localizedMessage}"
                }
        }
    }

    private fun handleSignInResult(result: ActivityResult) {
        try {
            val credential = oneTapClient.getSignInCredentialFromIntent(result.data)
            val idToken = credential.googleIdToken
            when {
                idToken != null -> {
                    // Got an ID token from Google. Use it to authenticate
                    // with your backend.
                    errorText.text = "Token Success GOt token $idToken"

                    Log.d("onActivityResult", "Got ID token.")
                }

                else -> {
                    // Shouldn't happen.
                    Log.d("onActivityResult", "No ID token!")
                    errorText.text = "No ID token!"
                }
            }
        } catch (e: ApiException) {
            Log.d("onActivityResult", "ApiException No ID token!")
            errorText.text = "Exception $e \n${e.localizedMessage} \n${e.message} \n ${e.cause} \n${e.stackTrace}!"
        }
    }
}

求助需求:
希望尽量避免使用Firebase,求问如何获取更相关的调试信息?同时欢迎提供可测试的解决方案建议。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 14:37:04