简体   繁体   English

谷歌登录失败 com.google.android.gms.common.api.ApiException: 10:

[英]Google sign in failed com.google.android.gms.common.api.ApiException: 10:

So I'm Stuck on this frustrating issue.所以我被困在这个令人沮丧的问题上。 I am quite new to Google Auth on Firebase but I done everything the firebase docs instructed in how to integrate the Google SignIn Auth, yet I'm still receiving this weird Error in the console consisted of two parts:我对 Firebase 上的 Google Auth 很陌生,但我完成了 firebase 文档中关于如何集成 Google SignIn Auth 的所有说明,但我仍然在控制台中收到这个奇怪的错误,该错误由两部分组成:

12-03 11:07:40.090 2574-3478/com.google.android.gms E/TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLE

and also并且

Google sign in failed com.google.android.gms.common.api.ApiException: 10:

Before Anyone attempts to point out similar questions that have previously been asked on stack overflow, Here's what I have done till now after seen all the available solutions and yet non has resolved the error在任何人试图指出以前在堆栈溢出时被问过的类似问题之前,这是我在看到所有可用的解决方案之后到目前为止所做的事情,但尚未解决错误

  • I have my SHA1 fingerprint for my project我的项目有我的 SHA1 指纹
  • I have my OAuth 2.0 client ID, both, the android client id and the web client and in the requestIdToken() I have put the web client id .我有我的 OAuth 2.0 客户端 ID,包括 android 客户端 ID 和 Web 客户端,并且在 requestIdToken() 中我放置了Web 客户端 ID
  • I did not publish my project's APK on google play store.没有在 google play store 上发布我的项目的 APK。 which means I did not accidentally generate another SHA1 fingerprint.这意味着我没有意外生成另一个 SHA1 指纹。
  • I have followed step by step the Google Sign in Auth firebase docs.我已逐步遵循 Google Sign in Auth firebase 文档。

here is my code snippet:这是我的代码片段:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup);
    ButterKnife.bind(this);

    String webClientId = getString(R.string.web_client_id);


    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestIdToken(webClientId)
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);


    GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);


    googleLoginBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent signInIntent = mGoogleSignInClient.getSignInIntent();
            startActivityForResult(signInIntent, RC_SIGN_IN);
        }
    });

}



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        // The Task returned from this call is always completed, no need to attach
        // a listener.
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);

        try{

            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);

        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
            // [START_EXCLUDE]
            Toast.makeText(this, "Gooogle Auth failed", Toast.LENGTH_LONG);
            // [END_EXCLUDE]
        }

    }
}



private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    // [START_EXCLUDE silent]
    //showProgressDialog();
    // [END_EXCLUDE]

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        Toast.makeText(LoginActivity.this, "Successful Auth", Toast.LENGTH_LONG).show();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(LoginActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                        //updateUI(null);
                    }

                    // [START_EXCLUDE]
                    //hideProgressDialog();
                    // [END_EXCLUDE]
                }
            });
}

Basically problem is in the SHA1 key put on console please regenerate it and put again properly same project.基本上问题出在控制台上的SHA1密钥中,请重新生成它并再次正确放置相同的项目。

1)As the answers, make sure that your actual signed Android apk has the same SHA1 fingerprint as what you specified in the console of your Firebase project's Android integration section (the page where you can download the google-services.json ) 1)作为答案,请确保您实际签名的 Android apk具有与您在 Firebase 项目的 Android 集成部分(您可以下载google-services.json的页面)的控制台中指定的相同的SHA1指纹

For more info, see: Generate SHA-1 for Flutter app有关更多信息,请参阅: 为 Flutter 应用程序生成 SHA-1

2)On top of that go to the Settings of your firebase project (gear icon right to the Overview at the top-left area. Then switch to Account Linking tab. On that tab link the Google Play to your project. 2)最重要的是转到您的firebase项目的设置(齿轮图标在左上角区域的概述右侧。然后切换到帐户链接选项卡。在该选项卡上将Google Play链接到您的项目。

EDIT: Account Linking tab doesn't exist any more, instead :编辑:帐户链接选项卡不再存在,而是:

  1. Sign in to Firebase.登录 Firebase。
  2. Click the Settings icon, then select Project settings.单击设置图标,然后选择项目设置。
  3. Click the Integrations tab.单击集成选项卡。
  4. On the Google Play card, click Link .在 Google Play 卡上,点击Link

在此处输入图像描述

When using App Signing by Google Play and Firebase , you need to add the SHA-1 fingerprint of the App signing certificate (found on Google Play Console/ Release Management/ App signing certificate) to the Firebase Console/ Settings/ SHA certificate fingerprints使用Google PlayFirebase的 App Signing 时,您需要将App 签名证书的 SHA-1 指纹(可在 Google Play 控制台/发布管理/应用签名证书上找到)添加到 Firebase 控制台/设置/SHA 证书指纹

Updated location for the SHAs: Google Play Console > Release > Setup > App integrity SHA 的更新位置: Google Play Console > Release > Setup > App integrity

In My case, There is no problem with SHA-1就我而言, SHA-1没有问题

I have done GoogleAuth using Firebase .我已经使用Firebase完成了GoogleAuth

I forgot to add implementation 'com.firebaseui:firebase-ui-auth:4.3.1'我忘了添加implementation 'com.firebaseui:firebase-ui-auth:4.3.1'

And I put my own key instead of R.string.default_web_client_id , So that was the problem.我用自己的密钥代替了R.string.default_web_client_id ,所以这就是问题所在。 I added above dependency and replace R.string.default_web_client_id with my own key.我添加了上面的依赖项并用我自己的密钥替换R.string.default_web_client_id

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();

UPDATE : 18-Dec-2020更新:2020 年 12 月 18 日

We can also use without requestIdToken like below.我们也可以在没有requestIdToken的情况下使用,如下所示。 For this you must have to add your SHA1 to google console.为此,您必须将 SHA1 添加到谷歌控制台。

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();

I was facing the same issue, After checking around for a solution, from regenerating the finger print to linking the app on firebase to the Google play console and publishing the signed apk, the issue was actually because I was using the release SHA-1 on the firebase console.我遇到了同样的问题,在检查了解决方案之后,从重新生成指纹到将 Firebase 上的应用程序链接到 Google Play 控制台并发布签名的 apk,问题实际上是因为我使用的是 SHA-1 版本Firebase 控制台。

  • If you are still on debug mode, use the debug.keystore SHA1如果您仍处于调试模式,请使用 debug.keystore SHA1
  • Only use the release SHA1 if you are on production mode如果您处于生产模式,请仅使用发行版 SHA1

https://developer.android.com/studio/publish/app-signing.html https://developer.android.com/studio/publish/app-signing.html

My solution was a little different,我的解决方案有点不同,

After hours of trying various things.经过数小时尝试各种事情。 I found my solution:我找到了我的解决方案:

Using the steps listed here: https://stackoverflow.com/a/34223470/10575896使用此处列出的步骤: https ://stackoverflow.com/a/34223470/10575896

  1. Open Android Studio打开安卓工作室
  2. Open your Project打开你的项目
  3. Click on Gradle (From Right Side Panel, you will see Gradle Bar)单击 Gradle(从右侧面板,您将看到 Gradle 栏)
  4. Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)单击 Refresh(从 Gradle Bar 中单击 Refresh,您将看到 List Gradle 项目的脚本)
  5. Click on Your Project (Your Project Name form List (root))单击您的项目(您的项目名称表单列表(根))
  6. Click on Tasks点击任务
  7. Click on Android点击安卓
  8. Double Click on signingReport (You will get SHA1 and MD5 in Run Bar(Sometimes it will be in Gradle Console))双击signingReport(您将在运行栏中获得SHA1和MD5(有时会在Gradle控制台中))

The console will print out the SHA keys for both debug and release.控制台将打印出调试和发布的 SHA 密钥。 I had added the debug keys to firebase sometime in the past, but I had not added the release keys.我在过去的某个时候将调试密钥添加到了 firebase,但我没有添加发布密钥。

I simply added the SHA1 and SHA256 keys to firebase, and I was good to go.我只是将 SHA1 和 SHA256 密钥添加到 firebase,我很高兴。

If you have all configuration valid in firebase like SHA-1 and you have imported right google-services.json file still you are getting error then add the support email in firebase console如果您在 SHA-1 等 Firebase 中的所有配置都有效,并且您已导入正确的 google-services.json 文件,但您仍然收到错误消息,请在 Firebase 控制台中添加支持电子邮件

You have to add support email in fire base console Go to Project-> Setting -> General -> Public setting add Support Email您必须在 fire base 控制台中添加支持电子邮件转到项目->设置->常规->公共设置添加支持电子邮件

i was dealing with this problem for 2 days !我处理这个问题两天了! the problem was the clientId i used, was android type while i had to use web Aplication type Clientid .问题是我使用的 clientId 是 android 类型,而我必须使用 web 应用程序类型 Clientid 。 please consider this if you have the same problem ;)如果您有同样的问题,请考虑这一点;)

I had problems with each answer, so here is the solution that worked for me:我对每个答案都有问题,所以这是对我有用的解决方案:

First, add Firebase to your project:首先,将 Firebase 添加到您的项目中:

Go to Firebase web site -> Add Project -> Once when you create new project go to Add App and add your Android app转到Firebase网站 ->添加项目-> 创建新项目后转到添加应用程序并添加您的 Android 应用程序

Take care to add the exact package name and debug SHA-1 key.注意添加确切的包名称并调试 SHA-1 密钥。

You can generate debug SHA-1 key doing the following in Android Studio:您可以在 Android Studio 中执行以下操作生成调试 SHA-1 密钥:

On the right side open Gradle panel -> go to Tasks -> android -> run signingReport在右侧打开Gradle面板 -> 转到Tasks -> android -> 运行signingReport

Your SHA-1 key will be shown in Run window您的 SHA-1 密钥将显示在运行窗口中

Once when you register the app, download the config file.注册应用程序后,下载配置文件。 In the config .json file you can find your client_id : client -> oauth_client -> client_id在配置 .json 文件中,您可以找到您的client_idclient -> oauth_client -> client_id

Take care there are two client_id s.注意有两个client_id The one with "client_type": 3 worked for me with the following code:带有"client_type": 3的那个使用以下代码为我工作:

private fun requestSignIn(context: Context) {

    GoogleSignIn.getLastSignedInAccount(context)?.also { account ->
        onSignedIn(account)
        return
    }

    val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestScopes(Scope("https://www.googleapis.com/auth/spreadsheets"))
        .requestEmail()
        .requestIdToken("client_id_goes_here")
        .build()
    val client = GoogleSignIn.getClient(context, signInOptions)

    startActivityForResult(client.signInIntent, REQUEST_SIGN_IN)
}

Then in the onActivityResult:然后在onActivityResult中:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    if (requestCode == REQUEST_SIGN_IN) {
         if( resultCode == RESULT_OK) {
            GoogleSignIn.getSignedInAccountFromIntent(data)
                .addOnSuccessListener { account ->
                    onSignedIn(account)
                }
                .addOnFailureListener { e ->
                    Log.d("Fail", "Fail")
                }
          }
    }
}

In onSignedIn you should do the google sheet api callonSignedIn你应该做 google sheet api 调用

  1. Make you use .requestIdToken(getString(R.string.default_web_client_id)) when you Build GoogleSignInOptions :让您在Build GoogleSignInOptions时使用.requestIdToken(getString(R.string.default_web_client_id))
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();
  1. Add your debug.keystore 's SHA1 and SHA256 fingerprint to your Firebase project with the following steps:使用以下步骤将debug.keystore的 SHA1 和 SHA256 指纹添加到 Firebase 项目:
  2. Obtain the debug.keystore's fingerprints: Linux/Mac - keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore , Windows - keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore获取debug.keystore的指纹:Linux/Mac - keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore , Windows - keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
  3. Add these fingerprint's to your Firebases project's Android app section: https://support.google.com/firebase/answer/9137403?hl=en将这些指纹添加到您的 Firebases 项目的 Android 应用部分: https ://support.google.com/firebase/answer/9137403?hl=en

Yo guys, make sure that you have installed google play services in android studio SDK Manager.伙计们,请确保您已在 android studio SDK Manager 中安装了google play 服务 After I did it, rebuild unity project — all works fine.完成后,重建统一项目——一切正常。 在此处输入图像描述

I am not sure if this is the cause, but we might need to use the Web Client ID in the Android App before publishing it, read the following article,我不确定这是否是原因,但我们可能需要在发布之前在 Android App 中使用 Web Client ID,请阅读以下文章,

https://android-developers.googleblog.com/2016/03/registering-oauth-clients-for-google.html https://android-developers.googleblog.com/2016/03/registering-oauth-clients-for-google.html

After adding the SHA1 and SHA256 app signing certificates it still didn't work.添加 SHA1 和 SHA256 应用签名证书后,它仍然无法正常工作。 Once I added the SHA1 App upload certificate it worked :)一旦我添加了 SHA1 App 上传证书,它就可以工作了:)

添加 SHA1 和 SHA256 应用签名证书后,它就可以工作了。

It's 2022 and I spent 7 hours debugging this!现在是 2022 年,我花了 7 个小时调试这个! I am not a native Android developer so I didn't know what's what until now.我不是原生 Android 开发人员,所以直到现在我才知道是什么。

Here is how I made it to work.这是我如何使它工作的。

1) Make sure you have different build numbers between dev and prod! 1) 确保 dev 和 prod 之间的内部版本号不同!

There are 3 different builds/app in the world that you are playing with:您正在使用的世界上有 3 种不同的构建/应用程序:

  1. The one in Google Play Store that you can install.您可以在 Google Play 商店中安装的那个。 It has a build number associated with it, both in the Play Store and in the App -> tap and hold -> info.它在 Play 商店和应用程序中都有一个与之相关的内部版本号 -> 点击并按住 -> 信息。
  2. The one in Android Studio build that has release build flavor Android Studio 版本中具有发布版本风格的版本
  3. The one in Android Studio build that has debug build flavor Android Studio 版本中具有调试版本风格的版本

在此处输入图像描述

The debug one is the one you can attach the debugger (the bug icon!) and release is the one that you cannot. debug器是您可以附加调试器(错误图标!)的调试器,而release是您不能附加的调试器。

Whatever you do, make sure these are different or you will pull your hair why it works here and not there!无论你做什么,确保这些是不同的,否则你会拉扯你的头发,为什么它在这里起作用而不在那里!

Android: Tag > Build > Release > then immediately version bump Android:标签 > 构建 > 发布 > 然后立即版本提升

I am coming from a background that we tag and version right before the release.我来自我们在发布之前标记和版本的背景。 (eg backend) Here, if you do so, it messes everything up! (例如后端)在这里,如果你这样做,它会搞砸一切! So you should tag, then release, then version bump immediately!所以你应该立即标记,然后发布,然后版本更新!

Ideally, the Play store should be 1.1.7 , the release one should be 1.1.8 (yes, one version ahead as it's the one you are going to publish), and the debug one should be 1.1.8-debug .理想情况下,Play 商店应该是1.1.7 ,发布版本应该是1.1.8 (是的,提前一个版本,因为它是您要发布的版本),调试版本应该是1.1.8-debug

If you don't do so, and they are the same, Android OS is going to cache the packages/APKs.如果您不这样做,并且它们是相同的,Android 操作系统将缓存包/APK。 So even if you go and install the app from Play Store, it might use an Android Studio version that it has in cache, with its own certificate!因此,即使您从 Play 商店安装应用程序,它也可能使用缓存中的 Android Studio 版本,并带有自己的证书! (That took me 4 hours of not knowing why installing the same app from Play Store on two phones, yielded different behaviors -- one was using the cached APK from Android Studio USB builds.) (我花了 4 个小时才知道为什么在两部手机上从 Play 商店安装相同的应用程序会产生不同的行为——其中一个是使用来自 Android Studio USB 版本的缓存 APK。)

2) You need at least 4 different Oauth Client ID Keys from GCP! 2) 您需要至少 4 个来自 GCP 的不同 Oauth 客户端 ID 密钥!

At this point, you should be aware of the crazy system that you should create a "Web" OAuth Client ID for Android, and also a dummy Android one!在这一点上,您应该知道您应该为 Android 创建一个“Web”OAuth 客户端 ID 以及一个虚拟的 Android 客户端 ID 的疯狂系统! See this .看到这个

Yes, you need one "Web" key, and one "Android" key to have the GoogleSignIn work.是的,您需要一个“Web”密钥和一个“Android”密钥才能使用 GoogleSignIn。 You should use the "Web" one almost everywhere (except for doing server-side token validation, where you verify the audience/issuer of the JWT).您应该几乎在任何地方都使用“Web”(除了进行服务器端令牌验证,您可以在其中验证 JWT 的受众/发行者)。 Regardless, without the unused dummy "Android" one, it's not gonna work.无论如何,如果没有未使用的虚拟“Android”,它是行不通的。

However, the part that I didn't know was that you need 3 Android + 1 Web!但是,我不知道的部分是您需要 3 Android + 1 Web!

When you create an Android OAuth Client ID, it asks for a SHA-1.当您创建 Android OAuth 客户端 ID 时,它会要求提供 SHA-1。

在此处输入图像描述

And each of those 3 apps has its own certificates, aka SHA-1s.这 3 个应用程序中的每一个都有自己的证书,即 SHA-1。

How to get 3 SHA-1s?如何获得 3 个 SHA-1?

For 2 and 3 ( release and debug of Android Studio) you can get them from gradle via this solution .对于 2 和 3(Android Studio 的releasedebug ),您可以通过此解决方案从 gradle 获取它们。

在此处输入图像描述

For the Play Store one, you have to go to Play Console > App Integrity > App Signing and get the "App signing" certificate from there.对于 Play 商店,您必须转到 Play Console > App Integrity > App Signing 并从那里获取“应用签名”证书。 (The upload one should match your release one most likely.) (上传的应该最有可能与您的release相匹配。)

在此处输入图像描述

Now, go ahead and create these 3 Android Ouath Client Ids + 1 for Web and hopefully Google SignIn will work everywhere!现在,继续为 Web 创建这 3 个 Android Ouath 客户端 ID + 1,希望 Google SignIn 可以在任何地方使用!

在此处输入图像描述

在我在模拟器上工作的情况下,我按照步骤https://stackoverflow.com/a/46767856/6800637 ,除了放入https://console.firebase.google.com projectName/settings/general,我的签名密钥 sha1 和 sha256 我还输入了来自 [debug.keystore] 的密钥 sha1,当您按照上述步骤操作时会显示该密钥

This status code means that you are providing unknown server client id.此状态代码表示您提供了未知的服务器客户端 ID。

So I was able to resolve this issue by changing the OAuth Client ID at Android client:所以我可以通过在 Android 客户端更改 OAuth 客户端 ID 来解决这个问题:

googleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken("web application client id")
            .requestEmail()
            .build()

In https://console.developers.google.com/apis/credentials in your project you might need to generate: OAuth client ID -> Web Application and use this web application client id in your Android app.在您项目的https://console.developers.google.com/apis/credentials中,您可能需要生成:OAuth 客户端 ID -> Web 应用程序并在您的 Android 应用程序中使用此 Web 应用程序客户端 ID。

在此处输入图像描述

I had this problem recently when trying to use google sign in using Firebase.我最近在尝试使用 Firebase 使用 google 登录时遇到了这个问题。 I could fix it by updating requestIdToken in GoogleSignInOptions to the one provided as client_id in google-services.json file.我可以通过将 GoogleSignInOptions 中的 requestIdToken 更新为在 google-services.json 文件中作为 client_id 提供的那个来修复它。

These are all great answers, in case anyone else is trying to have multiple firebase projects for one app, ie development and production the trick is when you want to test production, you'll need to upload the APK to Google Play if you use Google Play to manage the signing of your app.这些都是很好的答案,以防其他人试图为一个应用程序拥有多个 firebase 项目,即开发和生产,诀窍是当您想测试生产时,如果您使用 Google,则需要将 APK 上传到 Google Play播放以管理您的应用程序的签名。 I used the internal testing track, and then it started working.我使用了内部测试轨道,然后它开始工作。

You cannot just install the APK on your device with your debug keys, because it does not match the production keys in Firebase.您不能只使用调试密钥在设备上安装 APK,因为它与 Firebase 中的生产密钥不匹配。

Another side note - as others have mentioned - for some reason you need to use the "web" OAuth client ID, NOT the Android OAuth client.另一个旁注 - 正如其他人所提到的 - 出于某种原因,您需要使用“网络”OAuth 客户端 ID,而不是 Android OAuth 客户端。 This is a really confusing thing for Google to do.这对谷歌来说是一件非常令人困惑的事情。

Although, the tutorial and the configuration page suggests to get the package name from the manifest file, it seems it is checked against the "applicationId" in the "app/build.gradle" file.尽管教程和配置页面建议从清单文件中获取包名称,但似乎已根据“app/build.gradle”文件中的“applicationId”检查它。

There are two places to set the package name I've found so far:到目前为止,有两个地方可以设置包名:

app/src/main/AndroidManifest.xml应用程序/src/main/AndroidManifest.xml

app/build.gradle android.defaultConfig.applicationId app/build.gradle android.defaultConfig.applicationId

In my case those two names were different.在我的情况下,这两个名字是不同的。 Earlier I had updated the package name in the first file but forgot to update in the build.gradle file.早些时候我在第一个文件中更新了包名,但忘记在 build.gradle 文件中更新。

如果你在颤抖,看看你在哪里初始化你的 GoogleSignIn,对我来说添加 clientId 参数在 iOS 上工作但打破了 android 试试

If you are having multiple apps under same Project in Firebase, make sure you are in the correct (App)com.xxx.yyy , that matchup with your current project you are doing in Android Studio.如果您在 Firebase 中的同一个项目下有多个应用程序请确保您在正确的 (App)com.xxx.yyy中,与您在 Android Studio 中执行的当前项目匹配。 Then change the sha1 in settings of Firebase under proper (App)com.xxx.yyy and download the Json accordingly past it at, In project level view apps->build->source .然后在适当的 (App)com.xxx.yyy 下更改 Firebase 设置中的 sha1 并相应地下载 Json,在项目级别查看apps->build->source

如果您没有为您的项目设置 SHA-1/SHA-256 哈希值,则可能会出现这种情况。

I double-checked everything on the firebase console, I have correctly added SHA keys also I was facing an error.我仔细检查了 firebase 控制台上的所有内容,我已经正确添加了 SHA 密钥,但我也遇到了错误。 After spending hours I found the error was due to not setting up OAuth Consent in Google Console.花了几个小时后,我发现错误是由于没有在 Google 控制台中设置 OAuth 同意。 So if any once facing the same issue please check this step as well, that might be your help you out.因此,如果有人遇到同样的问题,请检查此步骤,这可能会帮助您。

在此处输入图像描述

我遇到了同样的错误,我通过修复WEB_CLIENT_ID的值解决了它您可以在以下位置检查值:身份验证 -> 登录方法 -> 提供者(例如:Google) -> Web SDK 配置 -> Web 客户端 ID

if above help from other universe can't prevent Google making you fired from your company, below may be help you: edit file "build.gradle" (:app) in android{}, add these if missing, change file path, storePassword , keyAlias , keyPassword如果上述来自其他领域的帮助无法阻止 Google 让您被公司解雇,以下可能对您有所帮助:在 android{} 中编辑文件“build.gradle”(:app),如果缺少,请添加这些文件,更改文件路径, storePassword , keyAlias , keyPassword

 signingConfigs {
        debug {
            storeFile file('E:\\keystore.jks')
            storePassword '123456'
            keyAlias 'key0'
            keyPassword '123456'
        }
        release {
            storeFile file('E:\\keystore.jks')
            storePassword '123456'
            keyAlias 'key0'
            keyPassword '123456'
        }
    }
 buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug
        }
    }

Build/Clean Project Sync Now立即构建/清理项目同步

if still not working, run Debug app , magical will appear如果还是不行,运行Debug app ,神奇的会出现

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:Firebase:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter: Firebase: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Flutter:使用 google_sign_in 时出现 PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using google_sign_in com.google.android.gms.common.api.ApiException: 10 - com.google.android.gms.common.api.ApiException: 10 com.google.android.gms.common.api.ApiException: 10: - com.google.android.gms.common.api.ApiException: 10: Android Google 登录失败 com.google.android.gms.common.api.ApiException: 12500 - Android Google Sign In Failed com.google.android.gms.common.api.ApiException: 12500 PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null, null) 尝试在 flutter 中使用 googleSignIn 时 - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) When trying to use googleSignIn in flutter 未处理的异常:PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null) - Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null) PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Getting this error While Sign in with Google Play - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) Getting this error While Sign in with Google Play com.google.android.gms.common.api.ApiException:12500,在Google的Android Firebase项目中登录 - com.google.android.gms.common.api.ApiException: 12500, in android firebase project in google sign in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM