0

I don't know whats happening, but for some reason i always get a ClassDefNotFound Error when i try to add Google BaseGameUtils to my app project. I did all the steps from the Google Developer website, but still getting the ClassDefNotFound execption on GameHelper:

public GameHelper getGameHelper() {
    if (mHelper == null) {
        mHelper = new GameHelper(this, mRequestedClients);
        mHelper.enableDebugLog(mDebugLog);
    }
    return mHelper;
}

@Override
protected void onCreate(Bundle b) {
    super.onCreate(b);
    if (mHelper == null) {
        getGameHelper();
    }
    mHelper.setup(this);
}

The line mHelper = new GameHelper(this. mRequestedClients); throws the class exception.

I tried everything:

  • I tried preject cleaning
  • I tried export order
  • I checked every library

I don't know what i should try or do. BTW i am using eclipse as IDE and the latest ADT and BuildTools. My SDK and play services lib are also the latest version.

LogCat Error:

11-04 22:01:03.211: E/AndroidRuntime(19057): FATAL EXCEPTION: main
11-04 22:01:03.211: E/AndroidRuntime(19057): java.lang.NoClassDefFoundError: com.google.example.games.basegameutils.GameHelper
11-04 22:01:03.211: E/AndroidRuntime(19057):    at com.google.example.games.basegameutils.BaseGameActivity.getGameHelper(BaseGameActivity.java:77)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at com.google.example.games.basegameutils.BaseGameActivity.onCreate(BaseGameActivity.java:87)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at com.pi.rtest.MainActivity.onCreate(MainActivity.java:24)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.Activity.performCreate(Activity.java:5250)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.ActivityThread.access$700(ActivityThread.java:152)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.os.Looper.loop(Looper.java:137)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at android.app.ActivityThread.main(ActivityThread.java:5328)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at java.lang.reflect.Method.invokeNative(Native Method)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at java.lang.reflect.Method.invoke(Method.java:511)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-04 22:01:03.211: E/AndroidRuntime(19057):    at dalvik.system.NativeStart.main(Native Method)
Deniz Celebi
  • 888
  • 4
  • 14
  • 24
  • In your Java source, is GameHelper.java in the same package (com.google.example.games.basegameutils) as BaseGameActivity.java? – Michael Krause Nov 04 '14 at 21:38
  • Yes. They are in the same package. – Deniz Celebi Nov 04 '14 at 21:45
  • i think this link can help to you. http://stackoverflow.com/questions/8678630/noclassdeffounderror-for-code-in-an-java-library-on-android – aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Nov 05 '14 at 01:23
  • None of them worked for me – Deniz Celebi Nov 05 '14 at 12:12
  • The Play Games Services team is moving away from using BaseGameHelper: it's no longer being used in the samples on GitHub - https://github.com/playgameservices/android-basic-samples. You might want to try using the services without using helper. – class Nov 05 '14 at 23:57
  • But the readme on github says in all samples they are using BaseGameUtils? – Deniz Celebi Nov 06 '14 at 18:16
  • Yes that is true. BaseGameUtils is still in use however we have reduced it to just one class (`BaseGameUtils.java`) that has a lot of static methods rather than a heavier solution like `BaseGameActivity`. I have recently updated the instructions on how to get BaseGameUtils properly included in your Android Studio project. Instructions are here: https://developers.google.com/games/services/android/init – Sam Stern Nov 12 '14 at 22:42

1 Answers1

0

Okay, i fixed it by replaceing my eclipse version with a newer one. I don't know why this happened, but after updating everything else, this seemed like the only left thing and it worked.

Deniz Celebi
  • 888
  • 4
  • 14
  • 24