Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleApiClient is not configured to use the API required for this call

I'm trying to get latitude and longitude of a place using Google Places API.

I'm following this example: Google Directions Android

I configure the client like that:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

But then here:

PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
                    .getPlaceById(mGoogleApiClient, placeId);

I get the following error:

java.lang.IllegalArgumentException: GoogleApiClient is not configured to use the API required for this call.

How can I solve it?

I have the APIs activated on Google API console and I think I'm configuring it right, like the example.

like image 634
Daniel Viaño Avatar asked Sep 01 '16 20:09

Daniel Viaño


1 Answers

So, after discussing it with @Daniel, the solution is to use two differents GoogleApiClient instances: one for LocationServices API and another for Places API.

like image 128
Matias Elorriaga Avatar answered Sep 19 '22 09:09

Matias Elorriaga