Integrating Google API into libgdx project

泪湿孤枕 提交于 2020-01-16 18:07:09

问题


I have followed Aryan's suggestion from this question LibGDX and the GoogleApiClient setup/integration (first time) but can't seem to get it to work.

I created the ActionResolver and implemented it into my AndroidLauncher along with GameHelpListener, but the line gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); gives me an error, saying that GameHelper cannot be applied to this(AndroidLauncher)... I have been struggling with this for days now and can't seem to get anywhere. Any help would be appreciated.

This is my AndroidLauncher code

public class AndroidLauncher extends AndroidApplication implements AdHandler, GameHelper.GameHelperListener, ActionResolver {

// some code

@Override
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

// more code

    if (gameHelper == null) {
        gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        gameHelper.enableDebugLog(true);
    }
    gameHelper.setup(this);

// more code

}

My main class extends game, so I am assuming that this code needs to be in AndroidLauncher. Am I wrong about this?

Thanks


回答1:


Question link in above question using older version of Google Play Services.

Previously we're using BaseGameUtils utility module for Leaderboard and Achievement. (play service version <11.6.2)

In latest version of google play game service, BaseGameUtils not required. Inject below dependency in your android module and follow this thread.

implementation "com.google.android.gms:play-services-games:${gms_library_version}"
implementation "com.google.android.gms:play-services-auth:${gms_library_version}"


来源:https://stackoverflow.com/questions/55855307/integrating-google-api-into-libgdx-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!