I've got a huge problem with google play games services. Indeed, in some devices, when I try to launch my game, the api try to connect to the services : the play game window appears, then we saw the loading image (a circle), finally an error message comes in front "Unfortunately, Google Service has stopped". When we click on OK, the process restart ( the loading image, the message ...).
We use GameHepler to implements Google games service.
Here is the class AndroidLauncher :
public class AndroidLauncher extends AndroidApplication implements
AdControl, ActionResolver,
GameHelperListener, MultiplayerInterface, RoomUpdateListener,
RealTimeMessageReceivedListener, RoomStatusUpdateListener,
View.OnClickListener, OnInvitationReceivedListener {
protected AdView adView;
private GameHelper gameHelper;
private MonJeu monJeu;
private static final String AD_UNIT_ID = "XXXXXXXXXXXXXXXXXXXXX";
private final int SHOW_ADS = 1;
private final int HIDE_ADS = 0;
// Request codes for the UIs that we show with startActivityForResult:
final static int RC_SELECT_PLAYERS = 19070;
final static int RC_INVITATION_INBOX = 19071;
final static int RC_WAITING_ROOM = 19072;
final static int MAIN_SCREEN = 29070;
final static int GAME_SCREEN = 29071;
final static int POPUP_INVIT = 29072;
final static int LOADING_SCREEN = 29073;
// The participants in the currently active game
ArrayList<Participant> mParticipants = null;
String creatorId;
// Room ID where the currently active game is taking place; null if we're
// not playing.
String mRoomId = null;
// My participant ID in the currently active game
String mMyId = null;
// If non-null, this is the id of the invitation we received via the
// invitation listener
String mIncomingInvitationId = null;
// Are we playing in multiplayer mode?
boolean mMultiplayer = false;
protected Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SHOW_ADS: {
adView.setVisibility(View.VISIBLE);
break;
}
case HIDE_ADS: {
adView.setVisibility(View.GONE);
break;
}
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the layout
RelativeLayout layout = new RelativeLayout(this);
// Do the stuff that initialize() would do for you
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.numSamples = 5;
monJeu = new MonJeu(this, this, this);
View gameView = initializeForView(monJeu, cfg);
// Create and setup the AdMob view
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("XXXXXXXXXXXXXXXXXXXXX").build();
adView.loadAd(adRequest);
// Add the libgdx view
layout.addView(gameView);
// Add the AdMob view
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adParams.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(adView, adParams);
// Hook it all up
setContentView(layout);
if (gameHelper == null) {
gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
gameHelper.enableDebugLog(true);
}
gameHelper.setup(this);
}
@Override
public void showAds(boolean show) {}
@Override
public void onStart() {
super.onStart();
gameHelper.onStart(this);
}
@Override
public void onStop() {
super.onStop();
gameHelper.onStop();
}
@Override
public void onActivityResult(int requestCode, int responseCode,
Intent intent) {
super.onActivityResult(requestCode, responseCode, intent);
switch (requestCode) {
case RC_SELECT_PLAYERS:
break;
case RC_INVITATION_INBOX:
break;
case RC_WAITING_ROOM:
break;
default:
gameHelper.onActivityResult(requestCode, responseCode, intent);
}
}
@Override
public boolean getSignedInGPGS() {
return gameHelper.isSignedIn();
}
@Override
public void loginGPGS() {
try {
runOnUiThread(new Runnable() {
public void run() {
gameHelper.beginUserInitiatedSignIn();
}
});
} catch (final Exception ex) {
}
}
@Override
public void submitScoreGPGS(int score) {}
@Override
public void submitScoreOnlineGPGS(int score) {}
@Override
public void unlockAchievementGPGS(String achievementId) {}
@Override
public void getLeaderboardGPGS() {
if(getSignedInGPGS())
startActivityForResult(
Games.Leaderboards.getLeaderboardIntent(
gameHelper.getApiClient(), "XXXXXXXXXXXXXXXXXXXXX"), 100);
else
loginGPGS();
}
@Override
public void getAchievementsGPGS() {
if(getSignedInGPGS())
startActivityForResult(
Games.Achievements.getAchievementsIntent(gameHelper
.getApiClient()), 100);
else
loginGPGS();
}
@Override
public void onSignInFailed() {
}
@Override
public void onSignInSucceeded() {
}
This is the log :
11-12 22:41:48.974: V/ActivityManager(1096): Moving to STOPPED: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} (starting in stopped state)
11-12 22:41:49.624: D/GameHelper(26628): GameHelper: Debug log enabled.
11-12 22:41:49.624: D/GameHelper(26628): GameHelper: Setup: requested clients: 1
11-12 22:41:49.634: D/GameHelper(26628): GameHelper: onStart
11-12 22:41:49.634: D/GameHelper(26628): GameHelper: Connecting client.
11-12 22:41:49.744: V/WindowStateAnimator(1096): performShowLocked: mDrawState=HAS_DRAWN in WindowStateAnimator{4629d260 com.google.android.gms/com.google.android.gms.games.ui.signin.SignInActivity}
11-12 22:41:49.754: I/ActivityManager(1096): Displayed com.google.android.gms/.games.ui.signin.SignInActivity: +781ms
11-12 22:41:49.754: I/ActivityManager(1096): Timeline: Activity_windows_visible id: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} time:522233174
11-12 22:41:49.944: D/GameHelper(26628): GameHelper: onConnectionFailed
11-12 22:41:49.944: D/GameHelper(26628): GameHelper: Connection failure:
11-12 22:41:49.944: D/GameHelper(26628): GameHelper: - code: SIGN_IN_REQUIRED(4)
11-12 22:41:49.944: D/GameHelper(26628): GameHelper: - resolvable: true
11-12 22:41:49.944: D/GameHelper(26628): GameHelper: - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{438f22c8: android.os.BinderProxy@438f2268}}
11-12 22:41:49.954: D/GameHelper(26628): GameHelper: onConnectionFailed: WILL resolve because we have below the max# of attempts, 0 < 3
11-12 22:41:49.954: D/GameHelper(26628): GameHelper: onConnectionFailed: resolving problem...
11-12 22:41:49.954: D/GameHelper(26628): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{438f22c8: android.os.BinderProxy@438f2268}}
11-12 22:41:49.954: D/GameHelper(26628): GameHelper: Result has resolution. Starting it.
11-12 22:41:49.954: I/ActivityManager(1096): START u0 {flg=0x4000000 cmp=com.google.android.gms/.games.ui.signin.SignInActivity (has extras)} from pid -1
11-12 22:41:49.964: I/ActivityManager(1096): ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t-1} Support Split:false Is ScreenFull:true
11-12 22:41:50.004: V/ActivityManager(1096): Moving to RESUMED: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} (in existing)
11-12 22:41:50.004: V/ActivityManager(1096): Moving to PAUSING: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608}
11-12 22:41:50.004: D/ActivityManager(1096): resumeTopActivityLocked: Resumed ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608}
11-12 22:41:50.014: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.014: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.044: D/GameHelper(26628): GameHelper: onStop
11-12 22:41:50.044: D/GameHelper(26628): GameHelper: Client already disconnected when we got onStop.
11-12 22:41:50.074: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.094: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.114: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.144: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.154: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} state=PAUSING
11-12 22:41:50.194: V/ActivityManager(1096): Moving to PAUSED: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} (pause complete)
11-12 22:41:50.194: V/ActivityManager(1096): Moving to STOPPING: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} (finish requested)
11-12 22:41:50.204: D/ActivityManager(1096): resumeTopActivityLocked: Restarting ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608}
11-12 22:41:50.204: V/ActivityManager(1096): Moving to RESUMED: ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} (starting new instance)
11-12 22:41:50.204: V/ActivityManager(1096): Moving to PAUSING: ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608}
11-12 22:41:50.214: V/ActivityManager(1096): Moving to FINISHING: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f}
11-12 22:41:50.214: V/ActivityManager(1096): Moving to DESTROYING: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} (destroy requested)
11-12 22:41:50.244: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} state=PAUSING
11-12 22:41:50.244: D/ActivityManager(1096): allPausedActivitiesComplete: r=ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} state=PAUSING
11-12 22:41:50.264: V/ActivityManager(1096): Moving to PAUSED: ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} (pause complete)
11-12 22:41:50.264: V/ActivityManager(1096): Moving to STOPPING: ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} (stop requested)
11-12 22:41:50.294: V/ActivityManager(1096): Moving to DESTROYED: ActivityRecord{43834848 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608 f} (removed from history)
11-12 22:41:50.354: V/ActivityManager(1096): Moving to STOPPED: ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} (stop complete)
11-12 22:41:50.384: I/ActivityManager(1096): Displayed com.google.android.gms/.games.ui.signin.SignInActivity: +179ms (total +188ms)
11-12 22:41:50.384: I/ActivityManager(1096): Timeline: Activity_windows_visible id: ActivityRecord{43ef4e58 u0 com.google.android.gms/.games.ui.signin.SignInActivity t1608} time:522233808
11-12 22:41:50.384: V/WindowStateAnimator(1096): performShowLocked: mDrawState=HAS_DRAWN in WindowStateAnimator{460381b0 com.google.android.gms/com.google.android.gms.games.ui.signin.SignInActivity}
And when we've got the popup error, we can generate a report. And so, this is the strack trace of google play crash :
After several days of research, I've finally found the solution.
The main problem was the java.lang.outofmemory. This exception was thrown because when the consent screen would appear, google play service load in memory the icon of the application stored in the folder res. In our case, we've generate the icons of our game with a Photoshop plugin found in internet and the icons were too big.
So we've used this website to generate the new icons : http://makeappicon.com/ wich is more efficient than the photoshop plugin. The new icons are lighter and the exceptions is not longer thrown.
Hope this solution will help someone else ! :)