Android 应用程序未连接到 Google 播放服务

Android application doesnt connect to Google play services

我尝试将我的应用程序与 Google 播放服务连接,首先使用 Google+ 帐户登录。出现连接时播放服务的加载屏幕,但不知何故 googleApiClient 无法连接,我总是使用方法 "onConnectionFailed"。

Gradle 中的依赖项:

依赖项{

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.1'
compile 'com.android.support:support-v4:21.0.1'
compile 'com.google.android.gms:play-services-appinvite:7.8.+'
compile 'com.google.android.gms:play-services:7.8.+'
compile 'com.google.android.gms:play-services-drive:7.8.+'

创建时:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_multiplayer_turn_based);

        //signInButton = (Button) findViewById(R.id.sign_in_button);
        findViewById(R.id.sign_in_button).setOnClickListener(this);
        findViewById(R.id.sign_out_button).setOnClickListener(this);

        buttonCheckGames = (Button) findViewById(R.id.buttonCheckGames);
        buttonStartMatch = (Button) findViewById(R.id.buttonStartMatch);

        // Create the Google API Client with access to Plus and Games
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
                .addApi(Games.API).addScope(Games.SCOPE_GAMES)
                .addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)
                .setViewForPopups(findViewById(android.R.id.content))
                .build();


    }

登录:

 public void onClick(View v) {
            switch (v.getId()) {
                case R.id.sign_in_button:
                    mSignInClicked = true;
                    mTurnBasedMatch = null;
                    mGoogleApiClient.connect();
                    break;
                case R.id.sign_out_button:
                    mSignInClicked = false;
                    Games.signOut(mGoogleApiClient);


findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
                findViewById(R.id.sign_out_button).setVisibility(View.GONE);
                break;
            default:
                break;
        }
    }



@Override
protected void onStart() {
    super.onStart();

    //  Log.d(TAG, "onStart(): Connecting to Google APIs");
    mGoogleApiClient.connect();


}

"Play Games" 的登录屏幕弹出,但由于 "unknown problem with Google Play services" 错误而无法连接。

我使用开发控制台配置了应用程序:https://developers.google.com/games/services/console/enabling,涉及 sha1 密钥和 app_id,但我不知道问题是什么:/ 测试外部建议 Android API 21,最新"Play Games"-版本和互联网接入。也许有人可以帮助我,想实现这是我的学士论文。

好的,问题是我尝试连接了一秒钟 Activity,我在主 Activity 中再次尝试,它成功了:)