Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Google Firebase signin给出状态12501(不工作)、发行版版本变体和jks SHA_Android_Firebase_Release_Sha1_Google Signin - Fatal编程技术网

Android Google Firebase signin给出状态12501(不工作)、发行版版本变体和jks SHA

Android Google Firebase signin给出状态12501(不工作)、发行版版本变体和jks SHA,android,firebase,release,sha1,google-signin,Android,Firebase,Release,Sha1,Google Signin,我知道这个问题已经被很多人提出并得到了回答。 那么,我为什么又问这个问题呢?因为我尝试了这些解决方案,而且我确实关注了谷歌文档、教程和youtube。还是不走运 好吧,这就是我在项目中所做的 项目:谷歌签名 dependencies { classpath 'com.android.tools.build:gradle:2.2.0' classpath 'com.google.gms:google-services:3.0.0' } Gradle(模

我知道这个问题已经被很多人提出并得到了回答。

那么,我为什么又问这个问题呢?因为我尝试了这些解决方案,而且我确实关注了谷歌文档、教程和youtube。还是不走运

好吧,这就是我在项目中所做的

项目:谷歌签名

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
      }
Gradle(模块:应用程序)

LoginActivity.java

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

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

        findViewById(R.id.sign_in_button).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
                startActivityForResult(signInIntent, RC_SIGN_IN);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RC_SIGN_IN){
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result.isSuccess()){
                Toast.makeText(getApplicationContext(),"Nailed it",Toast.LENGTH_LONG).show();
            }else {
                Snackbar.make(mLoginFormView,result.getStatus().toString(),Snackbar.LENGTH_LONG).show();
                Toast.makeText(getApplicationContext(),"Messed",Toast.LENGTH_LONG).show();

            }
        }
    }
string.xml

<string name="web_client_key">123456789-clientwebapplication.apps.googleusercontent.com</string>
Oright,现在是Firebase控制台

  • 创建了包名为的项目
  • 添加了从jks文件生成的sha1指纹
  • 为google登录启用身份验证
我想就是这样,希望我提供了一切,
那么我在这里错过了什么呢

当我点击GoogleSign时,它会给我一个状态码为12501的错误。我不知道这里怎么了。有人吗


提前感谢。

当您构建您的
谷歌签名时,您使用的是字符串资源
web\u客户端密钥
。出于安全原因,您没有发布真正的密钥,而是使用示例值
123456789 clientwebapplication.apps.googleusercontent.com.

该示例值没有出现在发布的
google services.json
中,因此我无法将其与那里的值进行匹配。该值应为此块中定义的
客户端id

{
  "client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
  "client_type": 3
}
这就是你使用的值吗


获取web客户端ID的方法是使用字符串资源
R.string.default\u web\u client\u ID
,它由from
google services.json
生成。有没有理由不能这样做,必须定义自己的字符串资源?您是否尝试过使用
default\u web\u client\u id

如果您在firebase中添加所有SHA-1指纹,仍然会出现错误。然后(我遇到了此问题。在完成此步骤后,问题得到解决。)尝试以下步骤:

1.转到谷歌控制台API凭据页面

2.单击左侧选项卡中的凭据

3.已经存在两个默认的Android和Web OAuth客户端Id。您必须创建一个Android客户端和一个Web2.0客户端

4.转到Firebase。在项目设置中,下载google-services.json并粘贴到应用程序文件夹中

(一切正常,但您仍然无法登录google意味着可能存在OAuth问题。因此,请确保创建Android和Web客户端ID。最后,在凭证页面中,您有两个Android客户端和两个Web客户端ID。)


同样填写OAuth内容屏幕

是的,
client\u id
字符串与google-services.json匹配,我非常清楚
default\u web\u client\u id
。我也试过了。我遇到了和上面一样的问题,但这不是配置的问题。这似乎是ISP提供商的问题。我尝试了不同的ISP提供商,然后它似乎工作了。您是否构建了调试APK并尝试了使用它登录?显然,但不同的sha1解决方案在相同状态下失败了?它在调试中工作正常。但不是在释放中。
{
  "project_info": {
    "project_number": "{numeric-id}",
    "firebase_url": "https://project--123456789.firebaseio.com",
    "project_id": "project--123456789",
    "storage_bucket": "project--123456789.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:{numeric-id}:android:sfdjgsdkdfgsfs",
        "android_client_info": {
          "package_name": "reoxey.com.googlesignin"
        }
      },
      "oauth_client": [
        {
          "client_id": "{numeric-id}-androidkey.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "reoxey.com.googlesignin",
            "certificate_hash": "{sha1-from-jks-file}"
          }
        },
        {
          "client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "{android-key}"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 2,
          "other_platform_oauth_client": [
            {
              "client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
              "client_type": 3
            }
          ]
        },
        "ads_service": {
          "status": 2
        }
      }
    }
  ],
  "configuration_version": "1"
}
{
  "client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
  "client_type": 3
}