编辑:,它在我的平板电脑和另一部手机上运行得很好。所以这个问题与设备有关。有什么想法吗?我已经多次重新安装了所有与google相关的应用程序,但没有成功:/
当我试图连接GoogleApiClient时,我总是得到
onConnectionFailed:ConnectionResult{statusCode=RESOLUTION_REQUIRED, resolution=PendingIntent{13c5b37: android.os.BinderProxy@e07c8a4}, message=null}当我跑的时候
connectionResult.startResolutionForResult(this, RC_RESOLUTION);Intent数据为null。
我在这里非常迷茫,这里出了什么问题,以及RESOLUTION_REQUIRED在这个上下文中的实际含义。
也许这是有帮助的:如果我对Drive.API做同样的尝试,我会得到一个SIGN_IN_REQUIRED错误,这似乎是一个更常见的错误。
任何想法都将不胜感激!
package com.some.domain.signin;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.some.domain.activity.MainActivity;
import com.some.domain.application.ApplicationClass;
public class GoogleSignInActivity extends Activity implements GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks {
private static final String TAG = "T1_GSignInActivity";
private static final int RC_RESOLUTION = 9002;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "GoogleSignInActivity");
setupGoogleClient();
}
public static GoogleApiClient googleApiClient;
public void setupGoogleClient() {
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
ApplicationClass.getInstance().setGoogleClient(googleApiClient);
}
@Override
public void onStart() {
super.onStart();
googleApiClient.connect();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_RESOLUTION){
startNextActivity();
}
}
private void startNextActivity() {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Toast.makeText(this, "Connection failed:\n" + connectionResult.toString(), Toast.LENGTH_LONG ).show();
try {
connectionResult.startResolutionForResult(this, RC_RESOLUTION);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
Log.d(TAG, "onConnectionFailed:" + connectionResult);
}
@Override
public void onConnected(@Nullable Bundle bundle) {
Toast.makeText(this, "Connected.", Toast.LENGTH_LONG ).show();
}
@Override
public void onConnectionSuspended(int i) {
Toast.makeText(this, "Connection Suspended.", Toast.LENGTH_LONG ).show();
}
}发布于 2017-08-27 11:10:04
好吧,在我挣扎了两天之后,我通过重新安装google服务和google商店修复了它。当我在两个不同的设备上运行程序后,我才意识到这一点.
还应确保:
Google:i将我的调试和发布证书注册为OpenAuth2 (SHA-1)
Google Play: i将"PlayServices“中的游戏与我的游戏包名连接起来
Google-Services.json:被复制到app文件夹中,并包含所有我的证书(SHA-1)。
tester :我注册为测试员
发布于 2017-08-25 09:02:56
请在您的项目中导入Module项目BaseGameUtils
还添加了gradle文件
dependencies {
compile project(':BaseGameUtils')
// ...
}https://stackoverflow.com/questions/45876641
复制相似问题