0
嗨,我正在開發基於回合的多人在線Android應用程序使用谷歌玩遊戲服務。我已根據Google Play遊戲服務指南中的說明在Google開發者控制檯上配置了我的應用程序。我也在我的項目中導入了BasicGameUtils庫。但是,當我嘗試登錄到我的應用程序谷歌播放服務時,我總是得到以下錯誤。連接到谷歌播放服務時出錯
應用程序配置不正確。檢查包名稱和簽名證書是否與Developer Console中創建的客戶端ID匹配。另外,如果應用程序尚未發佈,請檢查您嘗試登錄的帳戶是否列爲測試人員帳戶。查看日誌以獲取更多信息。
請問有沒有人知道解決方案?
這裏是我的manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appsclubx.project">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<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"/>
<activity android:name="com.appsclubx.project.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
這是我的MainActivity
public class MainActivity extends Activity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
{
private GoogleApiClient mGoogleApiClient;
private static int RC_SIGN_IN = 9001;
private boolean mResolvingConnectionFailure = false;
private boolean mAutoStartSignInflow = true;
private boolean mSignInClicked = false;
public Button clk,outbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
clk= (Button) findViewById(R.id.click);
clk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSignInClicked = true;
mGoogleApiClient.connect();
}
});
outbtn= (Button) findViewById(R.id.out1);
outbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSignInClicked = false;
Games.signOut(mGoogleApiClient);
mGoogleApiClient.disconnect();
}
});
System.out.println("Main activity oncreate function called");
}
@Override
public void onConnected(Bundle bundle) {
Log.d("Error","User is sign in");
}
@Override
public void onConnectionSuspended(int i) {
mGoogleApiClient.connect();
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
Log.d("Error","Google Api client connection on start");
}
@Override
protected void onStop() {
super.onStop();
mGoogleApiClient.disconnect();
Log.d("Error =","Google Api client connection on Stop");
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
System.out.println("Google Api client connection failed");
Log.d("Error",""+connectionResult.getErrorCode()+""+connectionResult.getErrorMessage());
if (mResolvingConnectionFailure) {
// already resolving
return;
}
// if the sign-in button was clicked or if auto sign-in is enabled,
// launch the sign-in flow
if (mSignInClicked || mAutoStartSignInflow) {
mAutoStartSignInflow = false;
mSignInClicked = false;
mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this, mGoogleApiClient,
connectionResult, RC_SIGN_IN, getString(R.string.signin_other_error));
// Attempt to resolve the connection failure using BaseGameUtils.
// The R.string.signin_other_error value should reference a generic
// error string in your strings.xml file, such as "There was
// an issue with sign-in, please try again later."
}
Log.d("Switch =","Switch to screen");
}
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
if (requestCode == RC_SIGN_IN) {
mSignInClicked = false;
mResolvingConnectionFailure = false;
if (resultCode == RESULT_OK) {
mGoogleApiClient.connect();
} else {
// Bring up an error dialog to alert the user that sign-in
// failed. The R.string.signin_failure should reference an error
// string in your strings.xml file that tells the user they
// could not be signed in, such as "Unable to sign in."
BaseGameUtils.showActivityResultError(this,
requestCode, resultCode, R.string.signin_other_error);
}
}
}}
這是我的格拉德爾建立
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.appsclubx.project"
minSdkVersion 15
targetSdkVersion 24
versionCode 3
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile "com.google.android.gms:play-services-games:9.4.0"
compile "com.google.android.gms:play-services-plus:9.4.0"
compile project(':BaseGameUtils')
}