-2

Hi I integrated Google Play Services, in my LibGDX game, In Logs i have sucessfully Logged in GPGS

But when call GetLeaderBoardIntent to see leaderboard, the app crashes

Now in logs there is some issue with GL thread ,That i am not able to figure out

Please Help

@Override
    protected void onCreate (Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);     
        setUpGPS();
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        services=new AndroidLauncher();
        config.useWakelock=true;            
        initialize(new JetSkiMain(services), config);       
        Log.d("TAB", "oncreate");
    }

    private void setUpGPS() {
          if (gameHelper == null) {
           gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES
             | GameHelper.CLIENT_APPSTATE | GameHelper.CLIENT_PLUS);
           gameHelper.enableDebugLog(true);
          }
          gameHelper.setup(this);
          signin();
         }

     private void signin() {
          // Run this code on the main thread.
          runOnUiThread(new Runnable() {
           @Override
           public void run() {
            // Check if user is signed in
            try {
             // if not, attempt to sign in
             gameHelper.beginUserInitiatedSignIn();
            } catch (Exception e) {
             // Handle errors with an alert box
             AlertDialog.Builder alert = new AlertDialog.Builder(
               AndroidLauncher.this);
             alert.setTitle("Unable to sign in");
             alert.setMessage("The app was unable to sign in to Google+. An error occured.");
             alert.setPositiveButton("Ok", null);
             alert.show();
            }
           }
          });
         }

     @Override
        protected void onActivityResult(int requestCode, int resultCode,
                Intent intent) {
            super.onActivityResult(requestCode, resultCode, intent);
            gameHelper.onActivityResult(requestCode, resultCode, intent);
        }
    @Override
    public void gotomenu() {
        // TODO Auto-generated method stub
        Log.d("", "gotoMenu");
    }
    @Override
    public void levelUp() {
        // TODO Auto-generated method stub
        Log.d("", "levelUp");
    }
    @Override
    public void gameOver() {
        // TODO Auto-generated method stub
        Log.d("", "gameover");
    }
    @Override
    public void share() {
        // TODO Auto-generated method stub
        Log.d("", "share");
    }
    @Override
    public void Login() {
        // TODO Auto-generated method stub

    }
    @Override
    public void LogOut() {
        // TODO Auto-generated method stub

    }
    @Override
    public boolean getSignedIn() {
        // TODO Auto-generated method stub
        return false;
    }
    @Override
    public void submitScore(int score) {
        // TODO Auto-generated method stub
        Games.Leaderboards.submitScore(gameHelper.getApiClient(), Game_id.leaderBoard_id, score);

    }

    @Override
    public void showLeaderBoard() {
        // TODO Auto-generated method stub
        Log.d("", "show leaderboard");
        startActivityForResult(
                Games.Leaderboards.getLeaderboardIntent(
                  gameHelper.getApiClient(), "CggI14rnjEsQAhAH"), 1);
    }
    @Override
    public void showAchivement() {
        // TODO Auto-generated method stub
        Log.d("", "show achivement");
        startActivityForResult(
                Games.Achievements.getAchievementsIntent(gameHelper
                  .getApiClient()), 1); 
    }
    @Override
    public void buyJetSky_1() {
        // TODO Auto-generated method stub

    }
    @Override
    public void buyJetSky_2() {
        // TODO Auto-generated method stub

    }
    @Override
    public void onSignInFailed() {
        // TODO Auto-generated method stub

    }
    @Override
    public void onSignInSucceeded() {
        // TODO Auto-generated method stub

    }

    @Override

    public void unlockNextLevel() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_1);
    }

    @Override
    public void collectCoinInSingleGamePlay() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_2);
    }

    @Override
    public void unlockNewJetsky() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_3);
    }

    @Override
    public void scoreWithoutNos() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_4);
    }

    @Override
    public void collectPowersInSingleGamePlay() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_5);
    }

    @Override
    public void playSomeTimes() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_6);
    }

    @Override
    public void hitAnotherJetskyNumberOfTime() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_7);
    }

    @Override
    public void UnlockAllJetSky() {
        // TODO Auto-generated method stub
        Games.Achievements.unlock(gameHelper.getApiClient(),Game_id.achievement_8);
    }

    @Override
     public void onDestroy() {
      super.onDestroy();
     }
}

This same this happens when I call getAchievementsIntent and Tried yo submit score

The Logs are

That I have signed In

08-20 17:39:18.069: D/GameHelper(29377): GameHelper: onConnected: connected!
08-20 17:39:18.069: D/GameHelper(29377): GameHelper: succeedSignIn
08-20 17:39:18.069: D/GameHelper(29377): GameHelper: Notifying LISTENER of sign-in SUCCESS

The Fatal Exception Error

08-20 17:37:06.869: E/AndroidRuntime(28980): FATAL EXCEPTION: GLThread 2953
08-20 17:37:06.869: E/AndroidRuntime(28980): java.lang.NullPointerException
08-20 17:37:06.869: E/AndroidRuntime(28980):    at com.game.jetski.AndroidLauncher.showLeaderBoard(AndroidLauncher.java:119)
08-20 17:37:06.869: E/AndroidRuntime(28980):    at com.JetSky.GameMenu.render(GameMenu.java:122)
08-20 17:37:06.869: E/AndroidRuntime(28980):    at com.badlogic.gdx.Game.render(Game.java:46)
08-20 17:37:06.869: E/AndroidRuntime(28980):    at com.JetSky.JetSkiMain.render(JetSkiMain.java:41)
08-20 17:37:06.869: E/AndroidRuntime(28980):    at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:414)
08-20 17:37:06.869: E/AndroidRuntime(28980):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1463)
08-20 17:37:06.869: E/AndroidRuntime(28980):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)
Nipun David
  • 273
  • 2
  • 12
  • possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Selvin Aug 20 '14 at 12:16
  • I would suggest break up the startActivityForResult call so it is less of a chain, so you will be able to see what is null. – James 'Cookie' Cook Aug 20 '14 at 12:20
  • Thanks for the comments, but just to check my method calls, I made a new android project, created 3 buttons (sign-in, show leaderboard, show achievments)....And You knw what it worked on first excecution...so I guess something is conflicting Libgdx Lib with GPGS – Nipun David Aug 20 '14 at 12:30
  • I wouldn't have thought so I have been using GPGS and LibGDX for the last 18mth and not had these kind of issues – James 'Cookie' Cook Aug 20 '14 at 12:39
  • ok @James'Cookie'Cook, so if you meant the above code is ok and that you been working on LibGdx for 18, So I think I am missing something...I will go through the code again and double check the setting that are I have configured. Thanks – Nipun David Aug 20 '14 at 14:49

1 Answers1

0

Ok, I have resolved the issue.

The issue was that i should't have instantiated the instance of interface on my main Android class

    I_play_Event services;
    private GameHelper gameHelper;
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);     
        setUpGPS();
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
//      services=new AndroidLauncher();
        config.useWakelock=true;            
        initialize(new JetSkiMain(this), config);       
        Log.d("TAB", "oncreate");
    }

It should be something like

I_play_Event services;
        private GameHelper gameHelper;
        @Override
        protected void onCreate (Bundle savedInstanceState) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
     super.onCreate(savedInstanceState);
        setUpGPS();
      AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
      services=new AndroidLauncher();
      config.useWakelock=true;   
      initialize( new JetSkiMain(this), config);  

Well i guess this was on me

Thanks @James 'Cookie' Cook

Nipun David
  • 273
  • 2
  • 12