在 'com.google.android.gms:play-services-location:9.4.0' 无法导入导入 com.google.android.gms.location.places.Places
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
因此无法构建 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();
}
});
在 Google Play Services 的最新版本中,他们进一步分解了它,现在您需要包含 location
和 places
以便代码在要编译的问题:
dependencies {
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-places:9.4.0'
//.......
}
在'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();
}
});
在 Google Play Services 的最新版本中,他们进一步分解了它,现在您需要包含 location
和 places
以便代码在要编译的问题:
dependencies {
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-places:9.4.0'
//.......
}