Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

addApi(Games.API) is deprecated

I have this code:

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();

It says at the second line that "API" is deprecated but it doesn't give me something to use instead.

If I remove it, I get

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

like image 356
Ventura De Lucas Sánchez Avatar asked Jan 24 '26 21:01

Ventura De Lucas Sánchez


1 Answers

This entire method of accessing Google APIs 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).

The long term solution is to replace your current code with code based on GamesClient.

like image 59
stkent Avatar answered Jan 26 '26 12:01

stkent