[英]Error on connecting to google play services
嗨,我正在使用Google Play游戲服務開發基於回合的多人在線Android應用。 我已經按照Google Play游戲服務指南中的說明在Google Developer Console上配置了我的應用。 我也在項目中導入BasicGameUtils庫。 但是,當我嘗試在我的應用程序中登錄Google Play服務時,我總是會收到以下錯誤。
該應用程序配置不正確。 檢查程序包名稱和簽名證書是否與在開發人員控制台中創建的客戶端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);
}
}
}}
這是我的Gradel版本
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')
}
批准您的應用程序以連接到Google Play服務。 從URL獲取幫助: https : //developers.google.com/drive/android/auth
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.