【问题标题】:In 'com.google.android.gms:play-services-location:9.4.0' Unable to to import import com.google.android.gms.location.places.Places在“com.google.android.gms:play-services-location:9.4.0”中无法导入导入 com.google.android.gms.location.places.Places
【发布时间】:2016-08-26 07:11:33
【问题描述】:

'com.google.android.gms:play-services-location:9.4.0'

无法导入导入 com.google.android.gms.location.places.Places 因此无法构建GoogleApiClient,也无法使用Places.GeoDataApi.getPlaceById.

但是在'com.google.android.gms:play-services-location:8.4.0'我们可以正常使用。

mGoogleApiClient = new GoogleApiClient
                .Builder(this)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .enableAutoManage(this, this)
                .build();

Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId).setResultCallback(new ResultCallback<PlaceBuffer>() {
            @Override
            public void onResult(PlaceBuffer places) {
                if (places.getStatus().isSuccess() && places.getCount() > 0) {
                    final com.google.android.gms.location.places.Place myPlace = places.get(0);
                    Log.i(TAG, "Place found: " + myPlace.getName());
                    map.addMarker(new MarkerOptions()
                            .position(myPlace.getLatLng())
                            .title(myPlace.getName().toString())
                            .snippet(myPlace.getAddress().toString()));
                    map.moveCamera(CameraUpdateFactory.newLatLng(myPlace.getLatLng()));
                }
                places.release();
            }
        });

【问题讨论】:

    标签: android google-play-services google-places-api google-api-client


    【解决方案1】:

    在最新版本的 Google Play 服务中,他们将其进一步分解,现在您需要同时包含 locationplaces 才能编译问题中的代码:

    dependencies {
        compile 'com.google.android.gms:play-services-location:9.4.0'
        compile 'com.google.android.gms:play-services-places:9.4.0'
        //.......
    }
    

    【讨论】:

      猜你喜欢
      • 2019-04-17
      • 1970-01-01
      • 2021-06-12
      • 1970-01-01
      • 2021-08-17
      • 1970-01-01
      • 2022-01-13
      • 2022-01-10
      • 2022-01-16
      相关资源
      最近更新 更多