代码之家  ›  专栏  ›  技术社区  ›  Siarhei Oliver Drotbohm

Google play game服务错误代码400

  •  8
  • Siarhei Oliver Drotbohm  · 技术社区  · 7 年前

    有一个应用程序使用play games服务,但由于某种原因,它停止工作。 看起来有时我可以成功登录,但通常是-不。如果我检查API流量,大约有10%的人得到的响应代码为200,而其他人得到的响应代码为404。

    获取404的方法:

    • 游戏。应用。玩
    • 游戏。事件。记录

    当我试图检查日志中的错误时,我看到:

    11705-13707/com.google.android.gms W/GamesServiceBroker: Client connected with SDK 12171000, Services 11975436, and Games 54390036
    11705-9262/com.google.android.gms E/BoundService: No such BoundService for action: com.google.android.gms.auth.APP_CERT
    11705-9262/com.google.android.gms E/BoundService: No such BoundService for action: com.google.android.gms.auth.APP_CERT
    691-778/system_process E/PROXIMITY: ProximitySensor: unknown event (type=3, code=0)
    8876-8890/com.agminstruments.drumpadmachine V/FA: Inactivity, disconnecting from the service
    691-778/system_process E/PROXIMITY: ProximitySensor: unknown event (type=3, code=0)
    2254-2269/? I/PerfService: PerfServiceNative_getPackName
    11705-16860/com.google.android.gms E/Volley: [3966] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/games/v1/players/me?language=ru-RU
    11705-9262/com.google.android.gms E/PlayerAgent: Unable to load player g08394879143000804289
    11705-9262/com.google.android.gms W/PlayerAgent: {"errors":[{"domain":"global","reason":"invalid","message":"Invalid applicationId with value . Reason: No application ids specified."}],"code":400}
    3978-3978/com.google.android.play.games.ui I/SignInActivity: Transition from 8 to 11
    3978-3978/com.google.android.play.games.ui W/SignInActivity: onSignInFailed()...
    3978-3978/com.google.android.play.games.ui W/SignInActivity: Sign in failed during 8
    3978-3978/com.google.android.play.games.ui W/SignInActivity: ==> Returning non-OK result: 10002
    

    我不明白为什么消息“无效的applicationId with value”中没有ID因为我已经在应用程序中添加了id。此外,我还试图更改ID,在这种情况下,我得到了一个错误,ID xxxxxxxx未与我的应用程序链接。包裹名称

    我也仔细检查过了 Application ID , SHA 指纹,重新导入 google-services.json 还尝试手动添加 OAuth2 Client ID 来自链接的应用程序。检查播放服务说明,一切正常。 我还能查到什么?

    更新:

    尝试将播放服务更新到11.8.0并使用 GoogleSignInClient

     mGoogleSignInClient = GoogleSignIn.getClient(application, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
     activity.startActivityForResult(mGoogleSignInClient.getSignInIntent(), 312);
    

    但也出现了一个错误:

    com.google.android.gms.common.api.ApiException: 4: 
    
    4 回复  |  直到 7 年前
        1
  •  1
  •   Daniel Metzner    7 年前

    我还在设备上安装了“com.google.android.gms.common.api.ApiException:4”。 更新Google Play Games应用程序为我解决了这个问题。

    然后,我只需在我的应用程序中手动单击Google登录按钮。 我希望这有帮助!

    使用gms\U library\u版本“11.8.0” 我使用的代码:

     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //...
        mGoogleSignInClient = GoogleSignIn.getClient(this, new GoogleSignInOptions
                .Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build());
        //...
     }
    
    
    
    // when the button gets clicked
    public void startSignInIntent() {
        startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN);
    }
    
    
        @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    
        if (requestCode == RC_SIGN_IN) {
    
            Task<GoogleSignInAccount> task =
                    GoogleSignIn.getSignedInAccountFromIntent(intent);
    
            try {
                GoogleSignInAccount account = task.getResult(ApiException.class);
                onConnected(account);
            } catch (ApiException apiException) {
                String message = apiException.getMessage();
                if (message == null || message.isEmpty()) {
                    message = getString(R.string.signin_other_error);
                }
    
                onDisconnected();
    
                new AlertDialog.Builder(this)
                        .setMessage(message)
                        .setNeutralButton(android.R.string.ok, null)
                        .show();
            }
        }
    
        //...
      }
    
        2
  •  1
  •   Techies Software Solutions Inc    7 年前

    清除缓存和数据也是此错误的主要解决方案之一。

    1、转到“设置”>&燃气轮机;转到应用程序设置(在某些设备中,应用程序设置命名为应用程序)。 2、转到,所有应用程序>&燃气轮机;查找Google Play商店>&燃气轮机;清除数据和缓存 3.清除所有内容后,接下来需要强制停止应用程序。 此外,请查找谷歌服务框架>&燃气轮机;开放谷歌服务框架>&燃气轮机;清除缓存和数据 现在,重新启动设备并尝试下载应用程序。

        3
  •  1
  •   Omkar    7 年前

    如上所述 here. 错误代码4表示

    public static final int SIGN_IN_REQUIRED

    客户端试图连接到服务,但用户未连接 已登录。客户端可以选择不使用API继续。 或者,如果hasResolution()返回true,则客户端可以调用 启动tresolutionforresult(Activity,int)以提示用户登录。 登录活动返回后,返回RESULT\u OK进一步尝试 应该成功。

    常量值:4

    所以确保SHA-1 signing-certificate 谷歌开发者控制台中应用程序的指纹与用于签署您正在测试的APK的密钥相同。

    组装调试构建Android Studio时,请使用自己的调试键。您可以从

    右键单击项目目录中的应用程序文件夹->选择 "Open Module Settings" -&燃气轮机; "Signing" 选项卡->配置您在google开发控制台中提到的相同密钥。之后,导航到“构建类型”选项卡并选择您的签名配置。

    结账 this answer too.

        4
  •  0
  •   PN10    7 年前

    试试这个, 首先从调试Play services开始,

    • 在代码中启用调试播放服务>制作apk>安装在设备上>从android sdk中的“工具”文件夹打开“监视器”>将设备连接到PC>跑

    • 调试后,如果您收到以下消息

    “您有错误的OAUth2相关配置,请检查。详细信息 错误\u API\u控制台“”OnSignInFailed()上的未注册\u。。。"

    enter image description here

    只需在API ID客户端OAuth 2.0中复制/粘贴“应用程序签名证书”“SHA-1证书指纹”,而不是“上载证书”“SHA-1证书指纹”,它是来自密钥库的证书。

    这将完成你的工作!!

    到目前为止,google play games不再在本地连接。但当它被导入到google play商店时,它连接成功(google应用程序签名正是它应该做的:它将您的SHA1从“上传证书”更改为“应用程序签名”)。

    注: 以上图片摘自GitHub公开发行的其中一张。 希望这有帮助!!