GoogleApiClient未配置为使用此调用所需的API

Dan*_*año 5 android google-places-api

我正在尝试使用Google Places API获取某个地方的纬度和经度.

我正在关注此示例:Google Directions Android

我这样配置客户端:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API)
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
Run Code Online (Sandbox Code Playgroud)

但接下来:

PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
                    .getPlaceById(mGoogleApiClient, placeId);
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

java.lang.IllegalArgumentException: GoogleApiClient is not configured to use the API required for this call.
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

我在Google API控制台上激活了API,我认为我正在配置它,就像示例一样.

Mat*_*aga 7

因此,在与@Daniel讨论后,解决方案是使用两个不同的GoogleApiClient实例:一个用于LocationServices API,另一个用于Places API.