Hary
Hary

Reputation: 11

creating GamesClient object

I'm tring to connect my game with Google Play Games. My code:

GamesClient mGamesClient; 
//...
mGamesClient = new GamesClient(null, null, null, null, null, null, 0, null);
            Log.i("MyLog", "connecting");
            try{
                mGamesClient.connect();
                Log.i("MyLog", Boolean.toString(mGamesClient.isConnected()));
                Log.i("MyLog", mGamesClient.getCurrentAccountName());
            }
            catch (Exception e){
                Log.i("MyLog", e.toString());
            }

But it doesn't work.

FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.google.android.gms.games.GamesClient at com.mharezlakmh.myappp.MainActivity.onStart(MainActivity.java:85) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163) at android.app.Activity.performStart(Activity.java:5018) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2215) at android.app.ActivityThread.access$600(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4936) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558) at dalvik.system.NativeStart.main(Native Method)

What is wrong?

I think I should use constuructor:

mGamesClient = new GamesClient(...);

But constructor created with documentation doesn't work.

Upvotes: 1

Views: 667

Answers (1)

Bruno Oliveira
Bruno Oliveira

Reputation: 5076

You should not construct the GamesClient object directly. Instead, construct it using GamesClient.Builder.

GamesClient client = GamesClient.Builder(this, this, this).create();

Upvotes: 1

Related Questions