Skip to content
Advertisement

AbstractGoogleClientRequest and GoogleClientRequestInitializer class not found in com.google.api-client:google-api-client-android:2.0.0

My Android app with Cloud Endpoints says these classes do not exist

import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;

when using any version higher than 1.31.0 of the following import

implementation 'com.google.api-client:google-api-client-android:1.31.0'

The latest version is 2.0.0 but even 1.32.1 has the issue. Anything that is 1.31.0 or lower works.

This is what my code looks like (taken from this link):

    if (myApiService == null) {  // Only do this once
        MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
                new AndroidJsonFactory(), null)
                .setRootUrl("http://YOUR-PROJECT-ID.appspot.com/_ah/api/")
                .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
                    @Override
                    public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
                        abstractGoogleClientRequest.setDisableGZipContent(true);
                    }
                });
        // end options for devappserver
        myApiService = builder.build();
    }

    try {
        return myApiService.sayHi(params[0]).execute().getData();
    } catch (IOException e) {
        return e.getMessage();
    }

Is there a different way to be doing this in the new versions or is something else going on?

Advertisement

Answer

According to the documentation you shared and the code example you are following, it seems to be definitely an issue of the API version.

I highly recommend you to raise a new issue in this GitHub repository.

As soon as you receive a response in the repository, I would advise you to keep working with a lower version for the time being.

Advertisement