本文介绍了创建GamesClient物件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我特林连接我的游戏与谷歌玩游戏。
我的code:

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.

致命异常:主要java.lang.NoClassDefFoundError的:
  在com.google.android.gms.games.GamesClient
  com.mharezlakmh.myappp.MainActivity.onStart(MainActivity.java:85)在
  android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
    在android.app.Activity.performStart(Activity.java:5018)在
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
    在
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2215)
    在android.app.ActivityThread.access $ 600(ActivityThread.java:144)
    在
  android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1210)
    在android.os.Handler.dispatchMessage(Handler.java:99)在
  android.os.Looper.loop(Looper.java:137)在
  android.app.ActivityThread.main(ActivityThread.java:4936)在
  java.lang.reflect.Method.invokeNative(本机方法)的
  java.lang.reflect.Method.invoke(Method.java:511)在
  com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:791)
    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)在
  dalvik.system.NativeStart.main(本机方法)

什么是错的?

我想我应该用constuructor:

I think I should use constuructor:

mGamesClient = new GamesClient(...);

但随着文档创建构造函数不起作用。

But constructor created with documentation doesn't work.

推荐答案

您不应该直接构造GamesClient物件。相反,如果使用GamesClient.Builder构造它。

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

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

这篇关于创建GamesClient物件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:42