title: libGDX & Google Play Game Services "java.lang.RuntimeException: Unable to instantiate activity ComponentInfo"
body: <p>Ok, so I'm trying to implement Google Play Games Services into my libGDX game. I followed the tutorial here: <a href="http://helios.hud.ac.uk/u1070589/blog/?p=202" rel="nofollow">http://helios.hud.ac.uk/u1070589/blog/?p=202</a></p>
  
  <p>When i run my game on my nexus, it force closes and logcat gives this Fatal Exception:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ggtized.bb/com.ggtized.bb.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.ggtized.bb.MainActivity" on path: DexPathList...
  </code></pre>
  
  <p>Without the implementation, my game works fine. But the tutorial seems to have been a success for many and i want GPGS too..</p>
  
  <p>What is causing this error. I have no idea.. Can someone help and might tell me whats the problem? Thank you for your replies!!</p>
  
  <p>Here's my androidmanifest.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.ggtized.bb"
      android:versionCode="0"
      android:versionName="1"&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="9"
          android:targetSdkVersion="19" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
  
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;
          &lt;meta-data
              android:name="com.google.android.gms.games.APP_ID"
              android:value="@string/app_id" /&gt;
  
  
          &lt;activity
              android:name="com.ggtized.bb.MainActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
              android:label="@string/app_name"
              android:screenOrientation="portrait" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Here's my main Android activity:</p>
  
  <pre><code>    package com.ggtized.bb;
  
  import android.content.Intent;
  import android.content.pm.ActivityInfo;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.view.View;
  import android.view.Window;
  import android.view.WindowManager;
  import android.widget.RelativeLayout;
  import com.badlogic.gdx.backends.android.AndroidApplication;
  import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
  //import com.google.android.gms.ads.AdListener;
  import com.google.android.gms.ads.AdRequest;
  import com.google.android.gms.ads.AdSize;
  import com.google.android.gms.ads.AdView;
  import com.google.android.gms.games.leaderboard.Leaderboard;
  import com.google.android.gms.games.leaderboard.LeaderboardScoreBuffer;
  import com.google.android.gms.games.leaderboard.OnLeaderboardScoresLoadedListener;
  import com.google.example.games.basegameutils.GameHelper;
  import com.google.example.games.basegameutils.GameHelper.GameHelperListener;
  import com.ggtized.bb.GoogleInterface;
  import com.ggtized.bb.BGame;
  
  public class MainActivity extends AndroidApplication implements
          GameHelperListener, GoogleInterface {
      // ****AdMob
      private AdView adView; // small ad
  
      // First Ad Code
      private static final String ADCODE = "ca-app-pub-6026787001894298/9413212162";
      // First time an Ad is loaded
      boolean firstTime = true;
  
      // *************GPGS
      private GameHelper aHelper;
  
      private OnLeaderboardScoresLoadedListener theLeaderboardListener;
  
      public MainActivity() {
          aHelper = new GameHelper(this);
          aHelper.enableDebugLog(true, "MYTAG");
  
          // create a listener for getting raw data back from leaderboard
          theLeaderboardListener = new OnLeaderboardScoresLoadedListener() {
  
              public void onLeaderboardScoresLoaded(int arg0, Leaderboard arg1,
                      LeaderboardScoreBuffer arg2) {
                  System.out.println("In call back");
  
                  for (int i = 0; i &lt; arg2.getCount(); i++) {
                      System.out.println(arg2.get(i).getScoreHolderDisplayName()
                              + " : " + arg2.get(i).getDisplayScore());
                  }
              }
          };
      }
  
      // *************GPGS end
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // ****AdMob
          AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
          cfg.useGL20 = false;
  
          // *************GPGS
          aHelper.setup(this);
          // *************GPGS end
  
          // initialize(new Game(), cfg);
  
          this.getWindow().addFlags(
                  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  
          final RelativeLayout layout = new RelativeLayout(this);
  
          requestWindowFeature(Window.FEATURE_NO_TITLE); // no title is needed
  
          // Do the stuff that initialize() would do for you
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
          getWindow().clearFlags(
                  WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  
          // here we need to create the proper AdViews: one for the banner, and
          // one for the full screen one
          adView = new AdView(this);
          adView.setAdSize(AdSize.SMART_BANNER);
          adView.setAdUnitId(ADCODE); // Put in your secret key here
  
          // Here we create the instance of the MyApp and we pass it the
          // RequestHandler which implements the IReqHandler interface
          View gameView = initializeForView(new BGame(null, this), cfg);
  
          // Optionally populate the ad request builder.
          AdRequest adRequest = new AdRequest.Builder()
                  .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // Emulator
                  .addTestDevice("775A90563E174E374BC2617A3FD652B1") // testdevice
  
                  .build();
  
          adView.loadAd(adRequest);
  
          // Add the libgdx view
          layout.addView(gameView);
  
          // Add the AdMob view
          final RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                  RelativeLayout.LayoutParams.WRAP_CONTENT,
                  RelativeLayout.LayoutParams.WRAP_CONTENT);
  
          adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
          adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
  
          /*
           * // Setting the ad listener to check if the ad is loaded before adding
           * // view, solves the problem of skipping the first draw
           * adView.setAdListener(new AdListener() {
           * 
           * @Override public void onAdLoaded() {
           * 
           * if (firstTime) { firstTime = false; layout.addView(adView, adParams);
           * } } });
           */
          layout.addView(adView, adParams);
  
          // Setting the background adview to transparant also solves the problem
          // of skipping the ad draw
          adView.setBackgroundColor(Color.TRANSPARENT);
  
          // Hook it all up
          setContentView(layout);
  
          // **************AdMob end
  
  
      }
  
      @Override
      public void onResume() {
          super.onResume();
  
          if (adView != null) {
              adView.resume();
          }
  
      }
  
      @Override
      public void onPause() {
  
          // Pause the AdView.
          if (adView != null) {
              adView.pause();
          }
          super.onPause();
      }
  
      /** Called before the activity is destroyed. */
      @Override
      public void onDestroy() {
          // Destroy the AdView.
          if (adView != null) {
              adView.destroy();
          }
          super.onDestroy();
      }
  
      // ****************GPGS
  
       @Override
          public void onStart(){
              super.onStart();
              aHelper.onStart(this);
          }
  
          @Override
          public void onStop(){
              super.onStop();
              aHelper.onStop();
          }
  
          @Override
          public void onActivityResult(int request, int response, Intent data) {
              super.onActivityResult(request, response, data);
              aHelper.onActivityResult(request, response, data);
          }
  
          public void onSignInFailed() {
              System.out.println("sign in failed");
          }
  
          public void onSignInSucceeded() {
              System.out.println("sign in succeeded");
          }
  
          public void Login() {
              try {
              runOnUiThread(new Runnable(){
  
                  //@Override
                  public void run(){
                      aHelper.beginUserInitiatedSignIn();
                  }
                  });
              }catch (final Exception ex){
  
              }
          }
  
          public void LogOut() {
              try {
              runOnUiThread(new Runnable(){
  
                  //@Override
                  public void run(){
                      aHelper.signOut();
                  }
                  });
              }catch (final Exception ex){
  
              }
  
          }
  
          public boolean getSignedIn() {
              return aHelper.isSignedIn();
          }
  
          public void submitScore(int _score) {
              System.out.println("in submit score");
              aHelper.getGamesClient().submitScore(getString(R.string.leaderBoardID), _score);    
          }
  
          public void getScores() {
              startActivityForResult(aHelper.getGamesClient().getLeaderboardIntent(getString(R.string.leaderBoardID)), 105);  
          }
  
          public void getScoresData() {
              aHelper.getGamesClient().loadPlayerCenteredScores(theLeaderboardListener,
                      getString(R.string.leaderBoardID), 
                      1, 
                      1, 
                      25) ;
          }
          // *************GPGS end
  }
  </code></pre>
  
  <p>And here's my Main Game Class</p>
  
  <pre><code>    package com.ggtized.bb;
  
  import com.badlogic.gdx.ApplicationListener;
  import com.badlogic.gdx.Game;
  import com.ggtized.Screens.SplashScreen;
  import com.ggtized.BHelpers.AssetLoader;
  import com.ggtized.BHelpers.IReqHandler;
  
  public class BGame extends Game implements ApplicationListener {
  
      // Code for Ads
      public static IReqHandler ExternalHandler;
  
      // *****GPGS
      private GoogleInterface platformInterface;
  
      public BGame(IReqHandler irh, GoogleInterface aInterface) {
  
          BGame.ExternalHandler = irh;
  
          platformInterface = aInterface;
          platformInterface.Login();
      }
  
      @Override
      public void create() {
          AssetLoader.load();
          setScreen(new SplashScreen(this));
      }
  
      @Override
      public void dispose() {
          super.dispose();
          AssetLoader.dispose();
      }
  
  }
  </code></pre>