我是Android的Google Play服务开发新手。我正在按照一个示例Type-a-Number Challenge来演示登录,成就和排行榜。 Link here. 一切正常,除非当我通过单击“取消”按钮选择帐户时取消登录流程时,我的应用程序崩溃。
错误日志:
03-23 06:30:20.039: E/AndroidRuntime(28837): java.lang.NoClassDefFoundError: com.google.android.gms.R$string
03-23 06:30:20.039: E/AndroidRuntime(28837): at com.google.android.gms.common.GooglePlayServicesUtil.b(Unknown Source)
03-23 06:30:20.039: E/AndroidRuntime(28837): at com.google.android.gms.common.GooglePlayServicesUtil.a(Unknown Source)
03-23 06:30:20.039: E/AndroidRuntime(28837): at com.google.android.gms.common.GooglePlayServicesUtil.getErrorDialog(Unknown Source)
03-23 06:30:20.039: E/AndroidRuntime(28837): at com.softhinkers.games.basegameutils.BaseGameUtils.showActivityResultError(BaseGameUtils.java:140)
03-23 06:30:20.039: E/AndroidRuntime(28837): at com.softhinkers.multiplayergamedemo.MainActivity.onActivityResult(MainActivity.java:430)
BaseGameUtils.showActivityResultError如下所示:
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
if (activity == null) {
Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
return;
}
Dialog errorDialog;
switch (actResp) {
case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
errorDialog = makeSimpleDialog(activity,
activity.getString(R.string.app_misconfigured));
break;
case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
errorDialog = makeSimpleDialog(activity,
activity.getString(R.string.sign_in_failed));
break;
case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
errorDialog = makeSimpleDialog(activity,
activity.getString(R.string.license_failed));
break;
default:
// *******Error Occurs here**********
//No meaningful Activity response code, so generate default Google
// Play services dialog
final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
activity, requestCode, null);
if (errorDialog == null) {
// get fallback dialog
Log.e("BaseGamesUtils",
"No standard error dialog available. Making fallback dialog.");
errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
}
}
errorDialog.show();
}
MainActivity.OnActivityResultError如下所示:
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (requestCode == RC_SIGN_IN) {
mSignInClicked = false;
mResolvingConnectionFailure = false;
if (resultCode == RESULT_OK) {
mGoogleApiClient.connect();
//*****Error occurs here*****
} else {
BaseGameUtils.showActivityResultError(this, requestCode,
resultCode, R.string.signin_other_error);
}
}
// added from Android game
if (!mGoogleApiClient.isConnecting()) {
// If Google Play services resolved the issue with a dialog then
// onStart is not called so we need to re-attempt connection
// here.
mGoogleApiClient.connect();
}
}
如果有人帮助我并告诉我如何纠正它,我将感激不尽。