こんにちは、Google Playゲームサービスを使用して、マルチプレイヤーのオンラインアンドロイドアプリを開発しています。 Google Playゲームサービスガイドに記載されている手順に従って、Google開発者コンソールで自分のアプリを設定しました。私はBasicGameUtilsライブラリを私のプロジェクトにインポートします。しかし、私は私のアプリで私はいつも次のエラーを取得するサービスをGoogleの再生サービスにログインしようとします。Google Playサービスへの接続時にエラーが発生しました
アプリケーションが正しく構成されていません。パッケージ名と署名証明書がデベロッパーコンソールで作成されたクライアントIDと一致することを確認します。また、アプリケーションがまだ公開されていない場合は、ログインしようとしているアカウントがテスターアカウントとしてリストされていることを確認してください。詳細はログを参照してください。
解決策はありますか?
はここにこれは私の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);
}
}
}}
である私の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>
あるこの私のgradelは、サービスをGoogle Playに接続するために
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')
}