无法使用11.0.2 Play服务连接到Google Games API

时间:2017-07-25 11:36:58

标签: android google-play-services google-play-games

我知道stackoverflow有很多关于这个问题的问题,但这个问题与最近的changes in games development有关。首先,没有严格的指南来集成Games API。至少我没有找到任何新鲜的东西。这一guide is for simple sign inBaseGameUtils不再适用于新的更改。尝试过 - 不起作用。也许有人已经遇到过这个问题。

我能够在mApiClient.hasConnectedApi(Games.API)方法上连接客户端,但false stull返回onConnected

我已经添加了SHA-1 keys for both release and debug versions,在Google控制台中,我看到了自动生成的Web和Android客户端ID。最后一个添加为字符串server_client_id。我也已经下载了google-services.json个文件。是的,Manifest有Meta数据:

 <meta-data
        android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />

 <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

我目前的代码:

的onCreate()

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
            //.requestServerAuthCode(getString(R.string.server_client_id))
            //.requestScopes(new Scope(Scopes.GAMES), new Scope(Scopes.PROFILE))
            .build();

    mApiClient = new GoogleApiClient.Builder(this)
            .addApi(Games.API)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            //.addScope(Games.SCOPE_GAMES)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

在onStart()

mApiClient.connect(GoogleApiClient.SIGN_IN_MODE_OPTIONAL);

onConnected()

 if (mApiClient.hasConnectedApi(Games.API)) { //always returns false
        Auth.GoogleSignInApi.silentSignIn(mApiClient).setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                // In this case, we are sure the result is a success.
                GoogleSignInAccount acct = googleSignInResult.getSignInAccount();

            }
        });
    } 

还尝试了this guide但它没有用。我根本无法登录,resolveIssue一直被召唤。猜猜它已经过时了。

有人会建议已经测试过的新鲜解决方案吗?

0 个答案:

没有答案