连接到Android游戏服务

时间:2014-07-14 22:54:44

标签: android

我已经摸不着头几天了,我希望有人可以帮助我。我正试图在我的游戏中实现排行榜,我无法弄清楚我做错了什么!当我的游戏启动时,我看到“正在连接到Google Play游戏”屏幕加载,然后我可以点击“登录”按钮。

之后,我收到一条消息“Google Play服务未知问题”。我浏览了文档和一些教程,但仍然无法弄清楚出了什么问题。

这是我的代码:

public class AndroidLauncher extends AndroidApplication implements GameInterface, GameHelper.GameHelperListener {

    protected RelativeLayout layout;
    protected GameHelper gameHelper;

    @Override
    public void onCreate (Bundle savedInstanceState) {
        gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        gameHelper.enableDebugLog(true, "GameHelper");

        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

         // Create the layout
        layout = new RelativeLayout(this);

        // Do the stuff that initialize() would do for you
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        // Create the libgdx View
        View gameView = initializeForView(new BirdBlast(this), config);

        layout.addView(gameView);

        gameHelper.setup(this);

        // Hook it all up
        setContentView(layout);

        if(!gameHelper.isSignedIn()) {
            gameHelper.beginUserInitiatedSignIn();
        }

    }


    @Override
    public void onActivityResult(int request, int response, Intent data) {
        super.onActivityResult(request, response, data);
        gameHelper.onActivityResult(request, response, data);
    }

    @Override
    public void onSignInFailed() {
        System.out.println("TEST: " + gameHelper.isSignedIn());
    }

    @Override
    public void onSignInSucceeded() {
        System.out.println("TEST: " + gameHelper.isSignedIn());
    }
}

这是我的logcat输出:

07-14 19:19:43.920  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onActivityResult: req=RC_RESOLVE, resp=RESULT_OK
07-14 19:19:43.920  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onAR: Resolution was RESULT_OK, so connecting current client again.
07-14 19:19:43.920  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: Starting connection.
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onConnectionFailed
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: Connection failure:
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper:    - code: INTERNAL_ERROR(8)
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper:    - resolvable: false
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper:    - details: ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null}
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onConnectionFailed: WILL resolve because user initiated sign-in.
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onConnectionFailed: resolving problem...
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null}
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: resolveConnectionResult: result has no resolution. Giving up.
07-14 19:19:44.871  25791-25791/com.mypackage.mygame W/GameHelper﹕ disconnect() called when client was already disconnected.
07-14 19:19:44.911  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: Notifying LISTENER of sign-in FAILURE (error)

1 个答案:

答案 0 :(得分:0)

昨天我遇到了同样的问题。 每次运行您的应用时,请尝试清除Google Play服务缓存。 另请查看完整日志,看看您是否从谷歌播放中收到任何403错误。 如果是这种情况,则可能需要从Google开发者控制台启用更多API