請按照Google Play Games Services docs已經爲您指定的步驟操作。
步驟1.登錄到谷歌Play開發者控制檯
步驟2將您的遊戲到谷歌Play開發者控制檯
第3步:生成一個OAuth 2.0客戶端ID
檢查GPGS Android Samples in Github。
我必須爲登錄功能編寫的實際代碼是什麼?
如何Implement Sign-in在您的Android遊戲
private static int RC_SIGN_IN = 9001;
private boolean mResolvingConnectionFailure = false;
private boolean mAutoStartSignInflow = true;
private boolean mSignInClicked = false;
// ...
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
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 = true;
// 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."
if (!BaseGameUtils.resolveConnectionFailure(this,
mGoogleApiClient, connectionResult,
RC_SIGN_IN, R.string.signin_other_error)) {
mResolvingConnectionFailure = false;
}
}
// Put code here to display the sign-in button
}
我得到這個錯誤: –
java.lang.NoSuchMethodError:沒有直接的方法。它指向mGoogleApiClient.connect()的主類;是 –