我尝试将我的应用与Google Play服务相关联,首先注销所有使用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.+'
的onCreate:
@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"作为一个弹出窗口,但由于Google Play服务的未知问题而无法连接#34;错误。
我使用开发控制台配置了应用程序:https://developers.google.com/games/services/console/enabling,涉及sha1密钥和app_id,但我不知道问题所在:/使用Android API 21测试外部建议,最新"玩游戏" -version和互联网访问。也许有人可以帮助我,想要实现这是我的学士论文。
答案 0 :(得分:2)
好的问题是我尝试连接第二个Activity,我在主Activity中再次尝试它并且它有效:)