Daniel Viaño Daniel Viaño - 3 months ago 261
Android Question

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.

Answer

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