addApi(Games.API) 已弃用

addApi(Games.API) is deprecated

我有这个代码:

apiClient = new GoogleApiClient.Builder(this)
        .addApi(Games.API)
        .addScope(Games.SCOPE_GAMES)
        .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
            @Override
            public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                Log.e(TAG, "Could not connect to Play games services");
                finish();
            }
        }).build();

它在第二行说 "API" 已被弃用,但它没有给我一些可以使用的东西。

如果我删除它,我得到

java.lang.IllegalArgumentException: must call addApi() to add at least one API

访问 Google API 的整个方法 is deprecated so it may be that those methods have all been deprecated to prompt developers to switch to the newer access method (1, 2)。

长期解决方案是将您当前的代码替换为 code based on GamesClient